我编写了一个函数来更新数据库表中名为 fsize
的字段,但我的函数不起作用。我不知道为什么。我调试了sqlite的错误代码,是0
,所以我不知道哪里出了问题。
void update_fsize(int asizex, char path[], int sizex) {
char *q;
q="UPDATE search SET ustat=0,fsize=? WHERE fpath=?";
if (sqlite3_prepare_v2(db, q, strlen(q), &pointer, 0) == SQLITE_OK) {
sqlite3_bind_int(pointer, 1, asizex);
sqlite3_bind_text(pointer, 2, path, strlen(path), 0); // file path
sqlite3_step(pointer); // prepare statemnt Ready
sqlite3_finalize(pointer);
}
int ecode = sqlite3_errcode(db);
cout << "\n error code is " << ecode;
cout << "\n\n\n Path: " << path << "\n actual size: " << asizex << "\n Recored size: " << sizex;
}
最佳答案
谢谢大家特别帮助我@WhozCraig :)
我会发布解决方案,也许其他人觉得它有用 伪代码:
function 1(){
// getting data from database
data if == to this
then
sqlite3_reset(pointer); // reset pointer
call db_updater();
db_updater(){
updating database using update query
}
所以在跳转到另一个函数之前重置指针
关于c++ - sqlite 更新查询在 C++ 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14375774/