我一直试图解决这个问题,问题似乎是以下代码底部的 if 语句失败:
sqlite3 *database;
if (sqlite3_open([[self dataFilePath] UTF8String], &database)
!= SQLITE_OK) {
sqlite3_close(database);
NSAssert(0, @"Failed to open database");
}
else
NSLog(@"Database opened successfully");
//CREATE THE TABLE HERE IF NEEDED
NSString *createSQL = @"CREATE TABLE IF NOT EXISTS workouts "" (ROW INTEGER PRIMARY KEY, FIELD_DATA TEXT);";
char *errorMsg;
if (sqlite3_exec(database, [createSQL UTF8String], NULL, NULL, &errorMsg) != SQLITE_OK) { sqlite3_close(database);
NSAssert(0, @"Error creating table: %s", errorMsg);
}
sqlite3_stmt *statement;
if (sqlite3_prepare_v2(database, [sqlStatement UTF8String],
-1, &statement, nil) == SQLITE_OK)
可能是什么问题呢?我知道还有很多其他因素涉及,但任何事情都会有所帮助。只需询问您是否需要任何其他信息。感谢 StackOverflow!
编辑:我收到的错误是:没有这样的列:columnName