Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8538591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:09:13+00:00 2026-06-11T11:09:13+00:00

I am trying to update sqlite db. This is the code I am using

  • 0

I am trying to update sqlite db. This is the code I am using

if(sqlite3_open([dbPath UTF8String], &database) == SQLITE_OK)
    {

        const char * sql;
        sql = "update tms  set name = ?,place=?,stars=?  where id=?";

        sqlite3_stmt *selectStatement;

        //prepare the select statement
        int returnValue = sqlite3_prepare_v2(database, sql, -1, &selectStatement, NULL);
        if(returnValue == SQLITE_OK)
        {
            sqlite3_bind_text(selectStatement, 1,[[payloadDict  valueForKey:@"userName"] UTF8String] , [[payloadDict  valueForKey:@"userName"] length],SQLITE_STATIC);
            sqlite3_bind_text(selectStatement, 2,[[payloadDict  valueForKey:@"locName"] UTF8String], [[payloadDict  valueForKey:@"locName"] length],SQLITE_STATIC);
            sqlite3_bind_int(selectStatement, 3, [[payloadDict  valueForKey:@"starCount"] integerValue]);
            sqlite3_bind_int(selectStatement, 4, [[payloadDict  valueForKey:@"rowid"] integerValue]);
            int success = sqlite3_step(selectStatement);
            if(success == SQLITE_DONE)
            {
                isExist = TRUE;
            }
            else {
                //NSAssert1(0,@"Error: Failed to Update %s",sqlite3_errmsg(database));
            }
    }

I am getting value 101 as success when sqlite3_step is executed. But database is not updated with new values.
How can I do this properly?
Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T11:09:15+00:00Added an answer on June 11, 2026 at 11:09 am

    I agree with @ott’s excellent suggestion of making sure the database is located in the Documents directory (though I would have thought that that would have given you an error).

    I’d also double check the value returned by [[payloadDict valueForKey:@"rowid"] integerValue] to make sure it matches a value in the id column for one of the existing rows in your table. If it doesn’t match anything, sqlite3_step will return SQLITE_DONE even if nothing was updated.

    Also note that you might also want to make sure that the id values are stored as numeric values, not text strings as sqlite is pretty lax about letting you store values in whatever data type you originally specified when you first inserted the data, regardless of how the table was defined), and I’m not sure if a WHERE clause looking for a numeric match will succeed if the data was originally stored as a text value. If you used an id column definition like id INTEGER PRIMARY KEY AUTOINCREMENT, where the system defined the values automatically for you, this isn’t an issue, but if you manually populated the id column, it might be something to double check. (Generally it does a pretty good job in interpreting strings as numbers on the fly, but there are some weird situations that are problematic: For example, if you stored a string value of “5,127” in a numeric field, if you later then try to retrieve its numeric value, sqlite won’t know what to do with the comma in the text value “5,127” and will interpret the numeric value as 5, not as 5127.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SQLite database, which needs to be updated. Using the update statement
I have a database file that is generated on a PC using Sqlite. This
I am trying update text views while this loop is processing. Here is my
Im trying to update a table with the following code. If I change WHERE
Im trying to update the contents of an element after running some php code.
I'm trying to update my code to use cv2.SURF() as opposed to cv2.FeatureDetector_create(SURF) and
I am trying to update a database with values from a csv file, the
I am trying to rename a field in my database through SQLite.net and am
I use a SQLite database and Entity Framework (with .net framework 3.5). I'm trying
I'm trying to use DbLinq with a SQLite database, but I'm running into a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.