开发者

sql won't add new entries. :(

开发者 https://www.devze.com 2022-12-11 22:20 出处:网络
My function won\'t add any entry to my existing sql database. Any ideas? sqlite3 *database; sqlite3_stmt *compiledStatement;

My function won't add any entry to my existing sql database. Any ideas?

    sqlite3 *database;

    sqlite3_stmt *compiledStatement;
    if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {

        NSString *tmpSQLStatement = [NSString stringWithFormat:@"INSERT INTO data (test) VALUES ('teststring');"];
        const char *sql = [tmpSQLStatement UTF8String];

        if(sqlite3_prepare_v2(database, sql, -1, &compiledStatement, NULL) != SQLITE_OK)
            NSAssert1(0, @"Error while creating add statement. '%s'", sqlite3_errmsg(database));


}                                                        开发者_开发知识库                                           
    }

No ERRORMESSAGE Is called. But unfortunately nothing is added.


After sqlite3_prepare_v2, you need to actually execute the statement by calling sqlite3_step. Values should be inserted by then.

0

精彩评论

暂无评论...
验证码 换一张
取 消