mercredi 9 septembre 2015

Insert records in sqlite database

i have a sqlite db and i want to insert record in it . I used this code , but the condition for the second if it seems that it's not true. Any ideea where i'm wrong?

-(void)InsertRecords{

    if (sqlite3_open([databasePath UTF8String], &contactDB) == SQLITE_OK){
    NSLog(@"New data, Insert Please");
    NSString *insertSQL = [NSString stringWithFormat:
                           @"INSERT INTO notes (category, title, content) VALUES (\"%@\", \"%@\", \"%@\")",
                           @"marin",
                           @"georgiana",
                           @"20"];

    const char *insert_stmt = [insertSQL UTF8String];
    sqlite3_prepare_v2(contactDB, insert_stmt, -1, &statement, NULL);
    if (sqlite3_step(statement) == SQLITE_DONE)
    {
        NSLog(@"data inserted");    }


    sqlite3_finalize(statement);
    sqlite3_close(contactDB);
    }

}

Aucun commentaire:

Enregistrer un commentaire