I want to update my database.I got the "done" message.But if i open the database the changes are not affected (ie) the database is not updated.
Can anyone tell me the solution?
Can anyone tell me the solution?
Code:
- (void)InsertdataintoDatabase
{
sqlite3 *the_pDatabase ;
sqlite3_stmt *addStmt;
if(sqlite3_open([m_pDatabasePath UTF8String], &the_pDatabase) == SQLITE_OK)
{
int count1=1;
NSString *date1=@"30-10-2009";
NSString *comments1=@"hi";
int id1=1;
NSString *sqlst = [NSString stringWithFormat:@"UPDATE tomato1 SET count='%d', date='%@', comments='%@' WHERE pk='%d'",count1,date1,comments1,id1];
const char *sql = [sqlst UTF8String];
if (sqlite3_prepare_v2(the_pDatabase, sql, -1, &addStmt, NULL) != SQLITE_OK) {
NSAssert1(0, @"Error: failed to prepare statement with message '%s'.", sqlite3_errmsg(the_pDatabase));
}
int success = sqlite3_step(addStmt);
if (success != SQLITE_DONE) {
printf("Not done");
}
else
{
printf("done");
}
}
sqlite3_reset(addStmt);
sqlite3_finalize(addStmt);
}