1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| NSFileManager *fileMgr = [NSFileManager defaultManager];
NSString *filePath = [[[NSBundle mainBundle] resourcePath ]stringByAppendingPathComponent:@"questionsdiverses.sqlite"];
BOOL success = [fileMgr fileExistsAtPath:filePath];
if(!success)
{NSLog(@"Cannot locate database file '%@'.", filePath);}
sqlite3_stmt *updateStmt;
if(!(sqlite3_open([filePath UTF8String], &db) == SQLITE_OK))
{NSLog(@"An error has occured.");}
const char *sql1 = [[NSString stringWithFormat:@"UPDATE tabledesdonnees SET dejajoue = 12 WHERE id = 1"] cStringUsingEncoding:NSUTF8StringEncoding];
if(sqlite3_prepare(db, sql1, -1, &updateStmt, NULL) != SQLITE_OK)
NSLog(@"Error while creating update statement. %s", sqlite3_errmsg(db));
sqlite3_reset(updateStmt);
if(SQLITE_DONE != sqlite3_step(updateStmt))
NSLog(@"Error while updating. %s", sqlite3_errmsg(db));
sqlite3_finalize(updateStmt);
} |
Partager