I'm using SQLite version 3 to run the following code.
//Run SQL SELCT query
sqlite3_prepare16_v2("SELECT * FROM table_name");
sqli开发者_StackOverflowte3_step();
//Need to review results in several iterations
for(int i = 0; i < n; i++)
{
//Seek to beginning
sqlite3_reset();
do
{
//Get values
sqlite3_column_int();
...
sqlite3_column_text16();
}
while(sqlite3_step() == SQLITE_ROW);
}
But for some reason the first batch of data I get is all 0's. What am I not doing correct in the code above?
Assuming what you are showing is pseudocode since you're missing many arguments to the sqlite3 funcitons...
You need a sqlite3_step
after sqlite3_reset
and before getting the first row of values.
You can change your do {
...} while(sqlite3_step() == SQLITE_ROW)
to a while(sqlite3_step() == SQLITE_ROW)
...}
to accomplish that.
This will also eliminate the need to step immediately after the sqlite3_prepare16_v2
精彩评论