我对 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
}