如何查看以下FMDatabase executeUpdate语句的成功?

时间:2015-05-23 14:31:40

标签: ios sql fmdb

以下代码不会给出任何错误,但不会执行插入操作,我无法弄清楚原因。我仍然是一个新手,想知道查看此查询结果的最佳方法或查看是否有错误消息。我确定它的东西很简单,比如“BOOL success = [database executeUpdate ...]然后打印BOOL。先谢谢。

  if (Search.Rank.ID > 0)
                {
                    y = y.Where(x => x.Rank != null && x.Rank.ID == Search.Rank.ID);
                }

1 个答案:

答案 0 :(得分:3)

executeUpdate方法有返回值而FMDatabase已保存lastErrorMessage

BOOL isSuccessful = [database executeUpdate:@"insert into CONDITION (condition_id, condition_name, condition_detail, condition_area, condition_date, active) values(?, ?, ?, ?, ?)",
    [NSNumber numberWithInt:self.condition_id], self.condition_name, self.condition_detail, self.condition_area, self.condition_date, [NSNumber numberWithInt:myInt] ];
if (!isSuccessful) {
    NSLog(@"%@", database.lastErrorMessage);
}