当我用这段代码插入记录时,我尝试了一些 sqlite 程序进行练习,它给出了一些错误
-(void) insertRecordIntoTableNamed:(NSString *) tableName
withField1:(NSString *) field1
field1Value:(NSString *) field1Value
andField2:(NSString *) field2
field2Value:(NSString *) field2Value {
NSString *sql = [NSString stringWithFormat:
@"INSERT INTO ‘%@‘ (‘%@‘, ‘%@‘) VALUES (‘%@‘,’%@‘)",tableName, field1, field2, field1Value, field2Value];
char *err;
if (sqlite3_exec(db, [sql UTF8String], NULL, NULL, &err) != SQLITE_OK) {
sqlite3_close(db);
NSAssert(0, @"Error updating table.");
}
}
错误信息是
** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Error updating table.'
我尝试通过终端插入数据并正确检索数据
所以请帮助我通过程序插入数据