Objective c iOS-SQLite未更新,但准备和步骤正在成功执行
标题几乎是我所有的信息,因为我找不到代码的问题。下面代码中使用的同一数据库实例能够成功地插入、删除和选择,但此功能不起作用。不返回任何错误代码(始终为0),并且程序在执行此函数后继续名义上运行 以下是表格信息:Objective c iOS-SQLite未更新,但准备和步骤正在成功执行,objective-c,ios,sql,sqlite,Objective C,Ios,Sql,Sqlite,标题几乎是我所有的信息,因为我找不到代码的问题。下面代码中使用的同一数据库实例能够成功地插入、删除和选择,但此功能不起作用。不返回任何错误代码(始终为0),并且程序在执行此函数后继续名义上运行 以下是表格信息: reminder (uniqueID integer primary key autoincrement, title text not null, details text, time integer) 有关守则: - (void) updateEntryData:(Reminder
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);
}
任何帮助都将不胜感激;我被难住了
编辑:忘了提到在进入sqlite控制台时使用的sql命令是有效的 只需删除参数周围的单引号即可。包装占位符将使其成为一个值,而不再是一个参数
char *updateCommand = "UPDATE reminder SET title = ?, details = ? .....";
是的,我就知道这会很愚蠢!非常感谢。我会接受你的回答,当它让我:)