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

The Archive Base Latest Questions

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

I am using sqlite database for store my data.But it is showing error of

  • 0

I am using sqlite database for store my data.But it is showing error of “database is locked” while insert query.Here is my code

 sqlite3_stmt    *statement;
        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
        const char *dbpath = [[defaults objectForKey:@"dbpath"] UTF8String];

        if (sqlite3_open(dbpath, &studentDB22) == SQLITE_OK)
        {
            NSString *insertSQL = [NSString stringWithFormat:@"INSERT INTO Emotion_videos (name) VALUES (\"%@\")",filePath];
            const char *query_stmt = [insertSQL UTF8String];
                if (sqlite3_prepare_v2(studentDB22, query_stmt, -1, &statement, NULL) == SQLITE_OK)
                {
                    NSLog(@"shi h2345");
                    if (sqlite3_step(statement) == SQLITE_ROW)
                    {
                        printf( "could not prepare statement: %s\n", sqlite3_errmsg(studentDB22));

                    }

                }
            sqlite3_finalize(statement);
        }
        else
        {
                   printf( "could not prepare statement: %s\n", sqlite3_errmsg(studentDB22));
        }

I am able to insert data for two or three times but when it runs again,it shows database locked error.

  • 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-13T13:29:12+00:00Added an answer on June 13, 2026 at 1:29 pm

    You open the database but you don’t close it.

    You shouldn’t use string formats to create queries. You should put ? placeholders in the query then bind the proper value. This takes care of things like properly quoting and escaping string values.

    NSString *insertSQL = @"INSERT INTO Emotion_videos (name) VALUES (?)";
    

    After you prepare the statement, call sqlite3_bind_text to bind the string value.

    Also. don’t use sqlite3_open, use sqlite3_open_v2. It’s better and gives you more control.

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

Sidebar

Related Questions

I am using an sqlite database to store log data. My table has a
I am using sqlite database for iphone app. but its crash on while loop
I'm using SQLite database. The problem is that data isn't written to base. NSLog
i was using SQLiteHelper to store data in a database, data was correctly stored
I'm using a sqlite3 database to store app's data. Instead of building a database
I need to store sensitive data in a sqlite database in an android app.
I am using a SQLite to store data in Android application . I need
I'm using a background thread to read from a Sqlite database some GPS data...and
I really like Xml for saving data, but when does sqlite/database become the better
I am new to android. I am using a database to store my data.

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.