【发布时间】:2010-08-13 07:40:34
【问题描述】:
从 sqlite3 文档看来,我应该能够使用以下语法来更新我 iPhone 上数据库中的一行:
NSString *dbFile = [[NSBundle mainBundle] pathForResource:@"database" ofType:@"db"];
sqlite3 *database = NULL;
if (sqlite3_open([dbFile UTF8String], &database) == SQLITE_OK) {
NSString *sql = [NSString stringWithFormat:@"update mytable set myfirstcolumn=%d, mysecondcolumn=%d where id=%d", int1, int2, int3];
sqlite3_exec(database, [sql UTF8String], MyCallback, nil, nil);
}
sqlite3_close(database);
但它不会更新数据库,甚至不会调用回调方法。这只是错误的语法,例如 sqlite3_exec() 无法执行更新?
在我的示例中,所有列名都是正确的,并且三个 int 值记录为正确的值,所以我有点没有想法......
谢谢。
【问题讨论】: