Reputation: 787
I want to save data to sqlite database but it does not work.
// 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);
What am I doing wrong?
Upvotes: 0
Views: 371
Reputation: 21826
You have to execute the statement using sqlite3_step as follows:
sqlite3_step(compiledStatement);
Upvotes: 1