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 8334347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:19:06+00:00 2026-06-09T03:19:06+00:00

I am working on sqlite database , trying to insert into database but it

  • 0

I am working on sqlite database , trying to insert into database but it is giving error “Error while inserting ” Database is locked .
I searched some post and also write reset and finalize statement but it is giving same error.

Here is my code

    if(addStmt == nil) 
    {
        //const char *sql = "insert into Limittabel (limitAmt) Values(?)";
        //const char *sql="INSERT INTO Limittabel (limitAmt, Profileid) VALUES(?, ?)";
        const char *sql="insert into Limittabel (limitAmt,Profileid) Values (?,?)";
       // Insert into Limittabel (limitAmt,Profileid) Values ($500,1)

        if(sqlite3_prepare_v2(database, sql, -1, &addStmt, NULL) != SQLITE_OK)
            NSAssert1(0, @"Error while creating add statement. '%s'", sqlite3_errmsg(database));
    }
    sqlite3_bind_text(addStmt, 1, [limitAmt UTF8String], -1, SQLITE_TRANSIENT);
//    NSString *str_id_poi = [[NSString alloc] initWithFormat:@"%d", [Profileid integerValue]];
//    sqlite3_bind_text(addStmt, 2, [str_id_poi UTF8String], -1, SQLITE_TRANSIENT);
    //sqlite3_bind_text(addStmt, 2, [ UTF8String], -1, SQLITE_TRANSIENT);
     NSLog(@"***Storing END on Database ***");
    if(SQLITE_DONE != sqlite3_step(addStmt))
    {
        NSAssert1(0, @"Error while inserting data. '%s'", sqlite3_errmsg(database));
    }  // sqlite3_finalize(addStmt);

    else{

        //sqlite3_last_insert_rowid;
        limitid = sqlite3_last_insert_rowid(database);
         NSLog(@"YES THE DATA HAS BEEN WRITTEN SUCCESSFULLY");
    }

    sqlite3_finalize(addStmt);
    }
    sqlite3_reset(addStmt);
    //sqlite3_finalize(addStmt);
}

If I am not opening the database it is giving Database locked error, if opening database it is giving ‘ No such Table ‘ error
Please Help me.
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-09T03:19:08+00:00Added an answer on June 9, 2026 at 3:19 am

    I don’t understand the “if I am not opening the database it is giving Database locked error” comment, because you simply can’t use a database without opening it. It makes no sense to call SQLite functions without first opening database. Maybe I’m not understanding this comment.

    But ignoring that for a second, you later say, “if opening database it is giving ‘No such table’ error”: Are you sure you’re finding the database correctly? The problem is, if you open database and it’s not found, then a blank database will be created. Are you sure this hasn’t happened to you? If this may have happened to you, you might want to

    1. Reset the simulator (if you’re using simulator) or delete and reinstall the app to make sure any blank databases that sqlite3_open may have created for you will be removed; and

    2. Check to make sure the database exists before you open it or replace your occurrence of sqlite3_open with sqlite3_open_v2 with a third parameter of SQLITE_OPEN_READWRITE and fourth parameter of NULL. See SQLite will not prepare query when accessing database in Xcode

    3. As an aside, you don’t mention whether you’re opening this from the bundle or Documents, but generally I advise to programmatically copy from bundle to Documents and then open it from there.

    4. If you’re doing this on the simulator, I sometimes find it helpful to examine the database used by the simulator from my Mac. Thus, I go to “~/Library/Application Support/iPhone Simulator/5.1/Applications/” (replace the 5.1 with whatever version of your simulator you are using … if the Library is hidden, unhide it from Terminal with chflags nohidden ~/Library), I then go into the directory for the particular application, go into it’s Documents folder, and then open the database in the Mac command line sqlite3 program. You can use that to examine the database and make sure the db is as you expect it.

    Just a few thoughts for the “no such table” error.

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

Sidebar

Related Questions

hello i am trying a sqlite database tutorial to build, but its not working
I'm working some code that inserts csv rows into an SQLite database using Python.
I'm trying to add a new entry into my database, but it's not working.
I am trying to insert a data into SQLite database using Python. INSERT INTO
I'm trying to insert some data in my Android SQLite freshly created Database with
I'm trying to insert data into SQLite using Phonegap. Its working fine when hard
I am working with sqlite database. I retrieve text data from sqlite database into
I'm working on an iPhone app, which uses the SQLite database, and I'm trying
I've been trying to get foreign keys working within my Android SQLite database. I
I am trying to insert text messages from an inbox to a SQLite Database,

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.