SQLite编程时遇到的问题,一直得不到解决

执行完下面的函数之后,再就不能对这个数据库进行update了(select查询可以)。请各位帮我看看问题出在哪里了?谢谢

void Function()
{
sqlite3 *db;
char *zErrMsg = 0;
int rc=0;
rc = sqlite3_open( CStringToChar(dbFilePath) ,&db);
rc = sqlite3_exec(db, "PRAGMA synchronous = OFF; ", 0,0,0);
if (rc)
{
CString str,str1;
str1 = _T("can't open database:");
CString str2( sqlite3_errmsg(db) );
str = str1+str2;
MessageBox(NULL,str,_T("warnning"),NULL);
return;
}
rc = sqlite3_exec(db,"begin;",0,0,0);
char *sqlStatement;
CString stateCString = _T("SELECT x,y from ") + toGetTableName + _T(";");
sqlStatement =CStringToChar(stateCString);
sqlite3_stmt *stmt = NULL;
int result = sqlite3_prepare_v2(db, sqlStatement,-1,&stmt,NULL);
if (result == SQLITE_OK)
{
while ( sqlite3_step(stmt)== SQLITE_ROW)
{
double x,y;
x = atof( (const char *) sqlite3_column_text(stmt,0));
y = atof( (const char *) sqlite3_column_text(stmt,1));
int Idnum;
Idnum =atoi( (const char *)sqlite3_column_text(stmt,2));
}
} 
sqlite3_finalize(stmt);
sqlite3_exec(db,"commit;",0,0,0);
sqlite3_close(db);
}

1个回答

看看是不是因为主键重复了。你update的查询没贴出来?

hanshiyan7291
hanshiyan7291 不是。把整个工程关闭,单独用update程序,可以成功更新数据库。
大约 2 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问