开发者

sqlite3 update text in uitextview

开发者 https://www.devze.com 2022-12-23 22:16 出处:网络
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 s

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;
    }
}


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号