我想知道是否有人可以帮我理解这段代码有什么问题.我从未通过sqlite3_prepare_v2语句,调试器说:
'NSInternalInconsistencyException',原因:'创建add语句时出错.'内存不足''
static sqlite3 *database = nil; sqlite3_stmt *addStmt = nil; if(addStmt == nil) { NSLog(@"About to add start time...\n"); const char *sql = "INSERT INTO games_played(start) VALUES(?)"; if(sqlite3_prepare_v2(database, sql, -1, &addStmt, NULL) != SQLITE_OK) NSAssert1(0, @"Error while creating add statement. '%s'", sqlite3_errmsg(database)); NSLog(@"add statement created successfully!\n"); } NSLog(@"About to bind start time...\n"); sqlite3_bind_text(addStmt, 1, @"start time", -1, SQLITE_TRANSIENT);
小智.. 26
我从未打开数据库...我认为这就是问题所在.
我从未打开数据库...我认为这就是问题所在.
它不是一个bug,问题是你永远不会打开数据库.例如:
if (sqlite3_open([dbPath UTF8String], &database) == SQLITE_OK)