以下代码假设更新存储在字符串 dbDate 中的 Date(Primary Key) = 今天日期的行中的 2 列(HoursWorked 和 TotalEarned)。我认为我的更新字符串可能写错了。正在触发警报视图。
sqlite3_stmt *newstatement;
sql =[NSString stringWithFormat:@"UPDATE HourLog SET HoursWorked = '%@', TotalEarned = '%@' WHERE Date ='%@'", HoursWorked, TotalEarned, dbDate];
if(sqlite3_prepare_v2(db, [sql UTF8String], -1, &newstatement, nil)==SQLITE_OK){
NSLog(@"details updated");
UIAlertView *alertDialog;
alertDialog = [[UIAlertView alloc]
initWithTitle:@"Title"
message:@"Details Updated!"
delegate:nil
cancelButtonTitle:@"Close"
otherButtonTitles: nil];
[alertDialog show];
sqlite3_step(newstatement);
}
sqlite3_finalize(newstatement);
sqlite3_close(db);