views:

22

answers:

1

i had the sqlite statement ready for update..but i am confuse about grabbing text from uitextview and updating it..and i waned to update it using a uibutton..how do i carry on after creating the sql statement???kinda lost..any new solution is appreciate..

- (void) saveAllData {

if(isDirty) {

    if(updateStmt == nil) {
        const char *sql = "update Snap Set snapTitle = ?, snapDesc = ?, Where snapID = ?";
        if(sqlite3_prepare_v2(database, sql, -1, &updateStmt, NULL) != SQLITE_OK)
            NSAssert1(0, @"Error while creating update statement. '%s'", sqlite3_errmsg(database));
    }

    sqlite3_bind_text(updateStmt, 1, [snapTitle UTF8String], -1, SQLITE_TRANSIENT);
    sqlite3_bind_text(updateStmt, 2, [snapDescription UTF8String], -2, SQLITE_TRANSIENT);
    sqlite3_bind_int(updateStmt, 3, snapID);
        if(SQLITE_DONE != sqlite3_step(updateStmt))
        NSAssert1(0, @"Error while updating. '%s'", sqlite3_errmsg(database));

    sqlite3_reset(updateStmt);

    isDirty = NO;
}

//Reclaim all memory here.
[snapTitle release];
snapTitle = nil;
[snapDescription release];
snapDescription = nil;

//isDetailViewHydrated = NO;

}

A: 

Instead of sqlite3_reset(updateStmt) I use sqlite3_finalize(updateStmt) and the code runs fine. Good luck!

rjobidon