Reputation: 57
In the SQLite3DB.cpp, I have some code blow:
void QueryJsFileBegin() {
SQLite3Initilize();
}
bool QueryJsFileNext(JS_FILE* js_file) {
int err = sqlite3_step(stmtQueryJSFILE);
if (err != SQLITE_ROW)
return false;
// get data.
return true;
}
void QueryJsFileEnd() {
sqlite3_reset(stmtQueryJSFILE);
}
These works fine when I test them in the SQLite3DB.cpp
void test () {
db::JS_FILE js_file;
for (db::QueryJsFileBegin(); db::QueryJsFileNext(&js_file); db::QueryJsFileEnd()) {
MessageBoxA(NULL, js_file.js_file_name_.c_str(), "", 0);
}
}
but When I use these in the other cpp(like main.cpp) file, It always return the first row and dead loops. Thanks for any help.
Upvotes: 0
Views: 828
Reputation: 16168
Because, in the step
part of for, you're running sqlite3_reset()
, so it is closed after first row.
Upvotes: 2