我想将数据保存到sqlite数据库,但它不起作用。
// Setup the database object
sqlite3 *database;
// Open the database from the users filessytem
if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
// Setup the SQL Statement and compile it for faster access
const char *sqlStatement = "INSERT INTO INCOMPLETECLAIM ( provideName,claimAmount, serviceType, receipentName, serviceStart, serviceEnd) VALUES(?, ?, ?, ?, ?, ?)";
sqlite3_stmt *compiledStatement;
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK)
{
// Loop through the results and add them to the feeds array
sqlite3_stmt *compiledStatement;
if (sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK){
//sqlite3_bind_text(compiledStatement, 1, [serStatus UTF8String], -1, SQLITE_TRANSIENT);
NSLog(@"testtt");
sqlite3_bind_text(compiledStatement, 2, [prName UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(compiledStatement, 3, [prAmnt UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(compiledStatement, 4, [gTps UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(compiledStatement, 5, [gRecipent UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(compiledStatement, 6, [gSSFSS UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(compiledStatement, 7, [myString UTF8String], -1, SQLITE_TRANSIENT);
}
}
// Release the compiled statement from memory
sqlite3_finalize(compiledStatement);
}
sqlite3_close(database);
我做错了什么?
答案 0 :(得分:1)
您必须使用sqlite3_step执行语句,如下所示:
sqlite3_step(compiledStatement);