SQLite3 - Updating database in Xcode
I struggling to update my database in xcode. I know the database is there and functioning on the device and the simulator. but I want to update one of the entries based on user input. The code looks like this:
sqlite3_stmt *updateStmt = nil;
if(updateStmt == nil) {
const char *sql = "UPDATE DATABASENAME SET LEVEL_DATA = ? WHERE ROW = ?";
if(sqlite3_prepare_v2(database, sql, -1, &updateStmt, NULL) != SQLITE_OK)
NSAssert1(0, @"Error while creating update statement. '%s'", sqlite3_errmsg(database));
}
sqlite3_bind_int(updateStmt, 1, level);
sqlite3_bind_int(updateStmt, 2, rowNum);
if(SQLITE_DONE != sqlite3_step(updateStmt))
NSAssert1(0, @"Error while updating. '%s'", sqlite3_errmsg(database));
sqlite3_reset(updateStmt);
Did I do something wrong? sometimes i see a SIGABRT type error, other times it just doesn't update , crash or do anything. I'm puzzled.
Last edited by Skyman; 07-31-2010 at 06:44 PM.
|