我正在尝试更新SQLite表但遇到以下错误。以下是我的代码。
我已按照早期线程中的建议关闭了数据库连接,但收到了同样的错误。任何帮助将不胜感激
-(bool)updateRecord:(NSString *)strRowID :(NSString *)strFilePath :(NSString *)strStatus
{
sqlite3 *objsqlite3temp;
const char *dbpath = [DATABASE_PATH UTF8String];
if (sqlite3_open(dbpath, &objsqlite3temp) == SQLITE_OK)
{
NSString *updatetSQL = [NSString stringWithFormat:@"UPDATE files set status='%@', path='%@' WHERE id = %@", strStatus,strFilePath,strRowID];
const char *insert_stmt = [updatetSQL UTF8String];
sqlite3_stmt *selectstmt;
if(sqlite3_prepare_v2(objsqlite3temp, insert_stmt, -1, &selectstmt, NULL) == SQLITE_OK)
{
while(sqlite3_step(selectstmt) == SQLITE_ROW)
{
// NSLog(@"Entered and return");
sqlite3_close(objsqlite3temp);
}
}
else
{
NSLog(@"Error message %s",sqlite3_errmsg(objsqlite3temp));
}
//ADD THIS LINE TO YOUR CODE
sqlite3_finalize(selectstmt);
}
else
{
sqlite3_close(objsqlite3temp); //Even though the open call failed, close the database connection to release all the memory.
}
return YES;
}