Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID
Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

Problem With SQLITE

KhurshidKhurshid Posts: 47Registered Users
hi
i have build an application that is using sqlite3. i can add and delete data from sqlite.
problem is with updating data.
i am using tableview to display account names, and when user select row from tableview, i display all detail about selected account in a detailview. here (in detail view ) user will see existing values and can change/update that value
now my problem is that updation is not taking place i can edit values but icant see updated values in sqlite DB or in table view.
any help regarding this will be appreciated

Thanks.
Post edited by Khurshid on

Replies

  • nestedloopnestedloop Posts: 75Registered Users
    Please post code of your Update method (the one where you update the data in the DB).
  • KhurshidKhurshid Posts: 47Registered Users
    nestedloop;382753 said:
    Please post code of your Update method (the one where you update the data in the DB).
    - (void) updateData {

    if(updateStmt == nil) {

    const char *sql = "update tbl Set f1 = ?,f2 = ?,f3 = ?,f4 = ?,f5= ?,f6 = ? Where ID = ?";
    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, [name UTF8String], -1, SQLITE_TRANSIENT);
    sqlite3_bind_text(updateStmt, 2, [a UTF8String], -1, SQLITE_TRANSIENT);
    sqlite3_bind_text(updateStmt, 3, [b UTF8String], -1, SQLITE_TRANSIENT);
    sqlite3_bind_text(updateStmt, 4, [c UTF8String], -1, SQLITE_TRANSIENT);
    sqlite3_bind_text(updateStmt, 5, [d UTF8String], -1, SQLITE_TRANSIENT);
    sqlite3_bind_text(updateStmt, 6, [he UTF8String], -1, SQLITE_TRANSIENT);

    sqlite3_bind_int(updateStmt, 7, uniqueId);

    if(SQLITE_DONE != sqlite3_step(updateStmt))
    NSAssert1(0, @"Error while inserting data. '%s'", sqlite3_errmsg(database));
    else
    //SQLite provides a method to get the last primary key inserted by using sqlite3_last_insert_rowid
    //uniqueId = sqlite3_last_insert_rowid(database);

    //Reset the add statement.
    sqlite3_reset(updateStmt);
  • nestedloopnestedloop Posts: 75Registered Users
    This seems alright... Have you checked if the variables (name, a, b, c, d, he, uniqueId) have the correct values when running the update function? I mean, after you modify the data in the UI, do they contain the new values, that are to be written in DB?

    Cheers.
  • KhurshidKhurshid Posts: 47Registered Users
    nestedloop;382758 said:
    This seems alright... Have you checked if the variables (name, a, b, c, d, he, uniqueId) have the correct values when running the update function? I mean, after you modify the data in the UI, do they contain the new values, that are to be written in DB?

    Cheers.
    thanks for your time i solved issue.
  • KhurshidKhurshid Posts: 47Registered Users
    nestedloop;382765 said:
    What was the problem?
    problem was with id (pk):)
    now i have set the value of PK to value of pk of data that is being edited:cool:
Sign In or Register to comment.