Reputation: 1581
I've been trying to figure this out for a while, and the problem seems to be that the if statement at the bottom of the following code is failing:
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)
What could be the problem? I know there are a lot of other factors involved, but anything would be helpful. Just ask if you want any additional info. Thanks StackOverflow!
edit: the error that i'm receiving is: no such column: columnName
Upvotes: 0
Views: 123
Reputation: 710
Honestly I wouldn't recreate any part of the Core Data framework unless you have a very good reason to do so. This tutorial might help you get started with Core Data programming http://www.raywenderlich.com/934/core-data-on-ios-5-tutorial-getting-started
Here's the reference page for Core Data: https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdBasics.html#//apple_ref/doc/uid/TP40001650
Upvotes: 1