Sqlite更新不起作用

时间:2014-06-25 16:31:23

标签: objective-c sqlite

我的更新数据库查询无效。我搜索并阅读了很多主题,但没有找到解决方案。我还有一个删除声明,它运作顺利。

我的代码:

//Checking for any previously open connection which was not closed
[self closeAnyOpenConnection];

//SqLite query
NSString *fetchQuery = [NSString stringWithFormat:@"Update Category Set CatOrder = '%d' where CatOrder = '%d'", withToIndex + 1, withFromIndex + 1];

const char *updateQuery = [fetchQuery UTF8String];

sqlite3_stmt *sqlStatement = nil;

if(sqlite3_prepare_v2(databaseReference, updateQuery, -1, &sqlStatement, NULL) == SQLITE_OK)
{
    // executes the sql statement with the data you need to update in the db
    sqlite3_step(sqlStatement);

    // clearing the sql statement
    sqlite3_finalize(sqlStatement);

    //closing the database after the query execution
    sqlite3_close(databaseReference);

0 个答案:

没有答案