需要更新detail viewcontroller中textfield的記錄。但是點擊了更新按鈕,會更新失敗。
-(IBAction)updateQuery:(id)sender
{
sqlite3_stmt *statement;
const char *dbpath = [databasePath UTF8String];
if (sqlite3_open(dbpath, &Information) == SQLITE_OK)
{
NSString *updateSQL = [NSString stringWithFormat: @"update CONTACTS set address=\"%@\",phone=\"%@\",imageUrl=\"%@\" WHERE name=\"%@\"",daddress.text,dphone.text,durl.text,dname.text];
const char *update_stmt = [updateSQL UTF8String];
sqlite3_prepare_v2(Information, update_stmt, -1, &statement, NULL);
if (sqlite3_step(statement) == SQLITE_DONE)
{
dstatuslabel.text=@"updated successfully";
}
else
{
dstatuslabel.text = @"Failed to update contact";
}
sqlite3_finalize(statement);
sqlite3_close(Information);
}
}
NSString *updateSQL = [NSString stringWithFormat: @"update CONTACTS set address='%@',phone='%@',imageUrl='%@' WHERE name='%@'",daddress.text,dphone.text,durl.text,dname.text];