我无法更新一个字段。请建议我的代码中有什么问题。
Code:
- (int) updateTaskDoneDate:(double)donedate ontaskid:(int)taskId
{
sqlite3 *database;
@try {
if (sqlite3_open([self.databasePath UTF8String], &database) == SQLITE_OK)
{
NSString *sql_str = [NSString stringWithFormat:@"update task set donedate='%f' where taskid=%d ", donedate ,taskId];
NSLog(@"sql str: %@",sql_str);
const char *sql = [sql_str UTF8String];
sqlite3_stmt *statement;
statement = [self PrepareStatement:sql];
NSDate *myDate;
myDate=[NSDate date];
int a1 = sqlite3_bind_double(statement, 1, [myDate timeIntervalSince1970]);
int a2 = sqlite3_bind_int(statement, 2, taskId);
NSLog(@"a1a2 %d, %d", a1, a2);
if (statement)
{
if (a1 != SQLITE_OK || a2 != SQLITE_OK)
{
sqlite3_finalize(statement);
return 0;
}
sqlite3_step(statement);
}
sqlite3_finalize(statement);
}
}
@catch (NSException *exception){
[self showException:exception];
}
@finally {
sqlite3_close(database);
return 1;
}
}