0

hii every one

can any one suggest me one good tutorial which shows update table in sqlite database

1 Answer 1

1

Open your database with:

sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK;

To update a row:

@synchronized(sqlLock]) {
    // Setup the SQL Statement and compile it for faster access
    const char *sqlStatement = [[NSString stringWithFormat:@"UPDATE TABLE Set Text = ? where ID = '%@'",objectID] UTF8String];
    sqlite3_stmt *compiledStatement;
    if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {     

        sqlite3_bind_text(compiledStatement, 1, [text UTF8String], -1, SQLITE_TRANSIENT);

        if(SQLITE_DONE != sqlite3_step(compiledStatement))
            NSAssert1(0, @"Error while updating. '%s'", sqlite3_errmsg(database));

        sqlite3_reset(compiledStatement);
    }
    // Release the compiled statement from memory
    sqlite3_finalize(compiledStatement);    
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.