我有Sqllite更新声明的问题,它无法正常工作。我不知道为什么因为一切似乎都好。错误代码为0
char *q; // query
char fp[MAX_PATH];
q="UPDATE search SET ustat=1 WHERE fpath=?";
for(int i=0; i<=6; i++){
if(sqlite3_prepare_v2(db, q, strlen(q), &pointer, 0) == SQLITE_OK){
//cout<<"\n\n inside loop i values is "<<i<<"\n\n";
snprintf(fp,MAX_PATH,xbx[i].fpaths,0);
sqlite3_bind_text(pointer, 1, fp, strlen(fp), 0); // file name
sqlite3_step(pointer); // prepare statemnt Ready
sqlite3_finalize(pointer);
}
}
我在绑定文本语句中使用了结构然后我想可能问题是由于结构然后我将其更改为本地缓冲区但没有成功。
更新:我尝试删除循环并手动设置,但更新语句仍然无法解决问题??????错误代码0
if(sqlite3_prepare_v2(db, q, strlen(q), &pointer, 0) == SQLITE_OK){
sqlite3_bind_text(pointer, 1, xbx[0].fpaths, sizeof(xbx[0].fpaths), 0); // file name
sqlite3_bind_text(pointer, 1, xbx[1].fpaths, sizeof(xbx[1].fpaths), 0);
sqlite3_bind_text(pointer, 1, xbx[2].fpaths, sizeof(xbx[2].fpaths), 0);
sqlite3_bind_text(pointer, 1, xbx[3].fpaths, sizeof(xbx[3].fpaths), 0);
sqlite3_bind_text(pointer, 1, xbx[4].fpaths, sizeof(xbx[4].fpaths), 0);
sqlite3_step(pointer); // prepare statemnt Ready
sqlite3_finalize(pointer); // delete prepared statement
}
答案 0 :(得分:0)
好吧我发现它是由于sqlite finalize语句的解决方案....检查你可能错过的所有程序,而不是放置sqlite finalize语句..所以问题解决了:))
if(sqlite3_prepare_v2(db, q, strlen(q), &pointer, 0) == SQLITE_OK){
//cout<<"\n\n inside loop i values is "<<i<<"\n\n";
snprintf(fp,MAX_PATH,xbx[i].fpaths,0);
sqlite3_bind_text(pointer, 1, fp, strlen(fp), 0); // file name
sqlite3_step(pointer); // prepare statemnt Ready
sqlite3_reset(pointer);
}
sqlite3_finalize(pointer);
}