【发布时间】:2012-12-14 20:08:27
【问题描述】:
标题几乎是我所拥有的所有信息,因为我找不到代码问题。下面代码中使用的同一数据库实例能够成功插入、删除和选择,但此功能不起作用。不返回错误码(始终为0),执行此函数后程序继续名义上运行。
这是表格信息:
reminder (uniqueID integer primary key autoincrement, title text not null, details text, time integer)
有问题的代码:
- (void) updateEntryData:(ReminderData *)data
{
sqlite3_stmt *statement;
char *updateCommand = "UPDATE reminder SET title = '?', details = '?', time = ? WHERE uniqueID = ?";
int e = sqlite3_prepare_v2(database, updateCommand, -1, &statement, nil);
if(e != SQLITE_OK) {
NSLog(@"Problem with updateEntryWithUniqueID");
NSLog(@"Error Code: %d, message '%s'", e, sqlite3_errmsg(database));
return;
}
sqlite3_bind_text(statement, 1, [data.title UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(statement, 2, [data.details UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_int(statement, 3, [data.time timeIntervalSince1970]);
sqlite3_bind_int(statement, 4, data.uniqueID);
NSLog(@"\nID: %d\nTitle: %@\nDetails: %@\nTime: %@", data.uniqueID, data.title, data.details, data.time);
if(sqlite3_step(statement) != SQLITE_DONE) {
NSLog(@"Problems updating entry in reminder");
}
/* Finished */
sqlite3_finalize(statement);
}
任何帮助将不胜感激;我难住了。
编辑:忘记提及使用的 sql 命令在进入 sqlite 控制台时有效。
【问题讨论】:
标签: objective-c ios sql sqlite