它成功打开了test.db文件,但是当我得到一些行时,它总是返回SQLITE_MISUSE:
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <winioctl.h>
#include <string.h>
#include <crtdbg.h>
#include <assert.h>
#include <fltuser.h>
#include "scanuk.h"
#include "scanuser.h"
#include <dontuse.h>
#include <sqlite3.h>
...
sqlite3 * db;
char * sql;
sqlite3_stmt * stmt;
int nrecs;
char * errmsg;
//int i;
int row = 0;
sqlite3_open("test.db", &db);
sql = "select * from table where key_value = '01FDF5479AE6E4051C4C3C413ED5CAE6'";
sqlite3_prepare_v2(db, sql, strlen(sql) + 1, &stmt, NULL);
while (1) {
int s;
s = sqlite3_step(stmt);
if (s == SQLITE_ROW) {
int bytes;
const unsigned char * text;
bytes = sqlite3_column_bytes(stmt, 0);
text = sqlite3_column_text(stmt, 0);
printf("%d: %s\n", row, text);
row++;
}
else if (s == SQLITE_DONE) {
break;
}
else {
fprintf(stderr, "Failed.\n");
//exit(1);
sqlite3_finalize(stmt);
sqlite3_close(db);
return FALSE;
}
}
sqlite3_finalize(stmt);
sqlite3_close(db);