Hi all,
I'm trying to insert some data in a table using sqlite3 on an iphone... All the error codes I get from the various steps indicate that the operation should have been successful, but in fact, the table remains empty...I think I'm missing something...
here the code:
sqlite3 *database = nil;
NSString *dbPath = [[[ NSBundle mainBundle ] resourcePath ] stringByAppendingPathComponent:@"placemarks.sql"];
if(sqlite3_open([dbPath UTF8String], &database) == SQLITE_OK){
sqlite3_stmt *insert_statement = nil;
//where int pk, varchar name,varchar description, blob picture
static char *sql = "INSERT INTO placemarks (pk, name, description, picture) VALUES(99,'nnnooooo','dddooooo', '');";
if (sqlite3_prepare_v2(database, sql, -1, &insert_statement, NULL) != SQLITE_OK) {
NSAssert1(0, @"Error: failed to prepare statement with message '%s'.", sqlite3_errmsg(database));
}
int success = sqlite3_step(insert_statement);
int finalized = sqlite3_finalize(insert_statement);
NSLog(@"success: %i finalized: %i",success, finalized);
NSAssert1(101, @"Error: failed to insert into the database with message '%s'.", sqlite3_errmsg(database));
sqlit3_step returns 101, so SQLITE_DONE, which should be ok..
If I execute the sql statement in the command line it works properly...
anyone has an idea? could it be that there's a problem in writing the placemarks.sql because it's in the resources folder?
rgds
Fra