I'd take this approach to determining why it fails.
1. Take the SQL code as it is and run it in your database directly, does it update correctly? Also, if your PK is an integer, then you don't require the single quotes around it.
2. If the update query works correctly in DB; ensure the database you are reviewing is the correct database file that the app is using.
I didn't see any obvious issues in your code that you provided.
Thank You for kind response....
I Already tried those approaches. Same Query Is working Fine directly....But through code it is not possible...
Insertion is perfectly executed..
+ (BOOL)updateEntryTable
{
sqlite3 *database;
sqlite3_stmt *update_statement;
NSString *stmt1 = [NSString stringWithFormat:@"UPDATE entryTab SET ebody='done very well' WHERE eid='1'"];
const char *sql = [stmt1 UTF8String];
if (sqlite3_open([[Utiliy databaseLocation] UTF8String], &database) == SQLITE_OK)
{
if (sqlite3_prepare_v2(database, sql, -1, &update_statement, NULL) != SQLITE_OK)
{
NSLog(@"Failed!!!!No databAse");
return NO;
}
int success = sqlite3_step(update_statement);
if (success == SQLITE_ERROR)
{
NSLog(@"Error: failed to insert into the database with message %@", sqlite3_errmsg(database));
return NO;
}
}
sqlite3_finalize(update_statement);
sqlite3_close(database);
return YES;
}
The insertion operation is successfully exicuted....While Updating It is exe uted with no error but Update operation is not done in the real database.
Thanks in advance.....
I can't spot what's wrong. I made up my update statement based on the existing add statement from a demo I downloaded. Mine does not look exactly like yours. I have some sqlite3_bind_.... commands, here's my update function for what it's worth, hope it helps:-
Thank you.....
My code is successfully executed.
The Error is not with this code.Before updating i am checking for record exist or not. that time i am not closing the database. So that the updating is not executed....