views:

965

answers:

2

Hi,

I'm wondering if someone can help me understand what is wrong with this block of code. I never get past the sqlite3_prepare_v2 statement and the debugger says :

'NSInternalInconsistencyException', reason: 'Error while creating add statement. 'out of memory''

    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);
+4  A: 

I never opened the database...I think thats the problem.

Thanks! I had this problem too :)
hatfinch
A: 

Hai,

I hope u might have the problem at opening the database from your application (or)at calling method in which u are going to insert the data. Once,Cross-check your application with the below link.

http://www.iphonesdkarticles.com/2008/10/sqlite-tutorial-adding-data.html