gpt4 book ai didi

iphone - 应用程序不断崩溃并出现 NSInternalInconsistencyException 错误 sqlite3 更新

转载 作者:行者123 更新时间:2023-11-29 04:19:55 24 4
gpt4 key购买 nike

我的 SQLLite3 更新功能有问题。我不知道是我的查询错误还是我构建的函数有问题。

- (void)updateRowWithID:(NSString *)databaseItem AndWithColumnName:(NSString *)changeColumnName AndWithValue:(NSString *)changeValue
{
NSString * sql = [NSString stringWithFormat:@"UPDATE tblUsers SET %@ = %@ WHERE ID = %@", changeColumnName, changeValue, databaseItem];

sqlite3_stmt * statement;
if(sqlite3_open([[self path]UTF8String], &database) == SQLITE_OK)
{
const char *insert_stmt = [sql UTF8String];

NSLog(@"UPDATE: %@",sql);

// here it says the something wrong and the application crush.
if(sqlite3_prepare_v2(database, insert_stmt, -1, &statement, NULL) != SQLITE_OK)
{
NSAssert(0, @"ERROR ON INSERTING TO TABLE");
}
int success = sqlite3_step(statement);
if(success)
NSLog(@"Success");
}
}

这是粉碎日志:

2012-10-27 22:07:47.088 myapplication[21778:15803] *** Assertion failure in -[userData updateRowWithID:AndWithColumnName:AndWithValue:], /Users/user/myapplication/userData.m:47
2012-10-27 22:07:47.089 myapplication[21778:15803] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'ERROR ON INSERTING TO TABLE'
*** First throw call stack:
(0x1a70022 0x1600cd6 0x1a18a48 0x133f2cb 0xcfc8 0xfcab 0x1a71e99 0x9ab14e 0x9ab0e6 0xa51ade 0xa51fa7 0xa51266 0x9d03c0 0x9d05e6 0x9b6dc4 0x9aa634 0x224fef5 0x1a44195 0x19a8ff2 0x19a78da 0x19a6d84 0x19a6c9b 0x224e7d8 0x224e88a 0x9a8626 0x2835 0x2735 0x1)
terminate called throwing an exception(lldb)

请告诉我,我在这里做错了什么?

谢谢!

最佳答案

调用sqlite3_errmsg()找出问题所在。

可能是表名或列名错误,或者数据库为空,因为 path 处的文件不存在。

关于iphone - 应用程序不断崩溃并出现 NSInternalInconsistencyException 错误 sqlite3 更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13103833/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com