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

  • SEARCH
  • Home
  • 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 7844625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:56:32+00:00 2026-06-02T16:56:32+00:00

I am creating an app, and doing update with sqlite. Here is my piece

  • 0

I am creating an app, and doing update with sqlite. Here is my piece of code given below:

    NSFileManager *fileMgr = [NSFileManager defaultManager];
    NSString *dbPath = [[[NSBundle mainBundle] resourcePath ]stringByAppendingPathComponent:@"appforoffice.sqlite"];
    BOOL success = [fileMgr fileExistsAtPath:dbPath];
    if(!success)
    {
        NSLog(@"Cannot locate database file '%@'.", dbPath);
    }
    if(!(sqlite3_open([dbPath UTF8String], &database) == SQLITE_OK))
    {
        NSLog(@"An error has occured.");
    }

    const char *sql = "UPDATE settings SET `value`='Off' WHERE `type`=?";
if(sqlite3_prepare_v2(database, sql, -1, &updateStmt, NULL) == SQLITE_OK)
    {
        if(sqlite3_bind_text(updateStmt, 1, [updateType UTF8String], -1, SQLITE_TRANSIENT) == SQLITE_OK)
        {
            if(sqlite3_step(updateStmt) == SQLITE_DONE) {
                NSLog(@"Update Done successfuly");
            }
            else {
                 NSLog(@"Error while updating. '%s'", sqlite3_errmsg(database));
            }

            sqlite3_finalize(updateStmt);
            sqlite3_close(database);
        }
        else
        {
            NSLog(@"Error while binding variable. '%s'", sqlite3_errmsg(database));
        }
    }
    else
    {
        NSLog(@"Error while creating update statement. '%s'", sqlite3_errmsg(database));
    }

But guys, I am not getting any error. But the problem is that, the database table is not being effected by the query. I am sure the query is perfectly alright.

I am confused about the problem, can’t find any way to get out of this.

  • 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-02T16:56:34+00:00Added an answer on June 2, 2026 at 4:56 pm

    sqlite3_prepare_v2() doesn’t return boolean, so testing its return value with ! is wrong. From the reference:

    On success, the sqlite3_prepare() family of routines return SQLITE_OK;
    otherwise an error code is returned.

    So your code should look more like this:

    if (sqlite3_prepare_v2(database, sql, -1, &updateStmt, NULL) == SQLITE_OK)
    {
        if (sqlite3_bind_text(updateStmt, 1, [updateType UTF8String], -1,
            SQLITE_TRANSIENT) == SQLITE_OK)
        {
            ... call update API ...
        }
        else
        {
            NSLog(@"Error while binding variable. '%s'", sqlite3_errmsg(database));
        }
    }
    else
    {
        NSLog(@"Error while creating update statement. '%s'", sqlite3_errmsg(database));
    }
    

    EDIT (after the question was updated with the whole query):

    I don’t like the look of the ` characters in the query; remove them and it should work.

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

Sidebar

Related Questions

I am creating an iPhone app for doing time entry against projects. My UI
I am creating an iPad app and want to update the user with the
I'm creating and app that will rely on a database, and I have all
I am creating an app that is having a UIWebView which contains an advert.
I am creating an app which will have a question in a UILabel and
I am creating console app, involving lots of services. I want to display a
I am creating an app that runs on the logitech revue. The UI is
hey I'm creating an app with two switches on it that change the background
I am creating an app which has around 15 different animations. Some animations are
I am creating an app on android but after hearing about sencha that it

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.