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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:09:28+00:00 2026-05-28T22:09:28+00:00

Im trying to use an sqlite database in xcode 4.2 and ios5 sdk. The

  • 0

Im trying to use an sqlite database in xcode 4.2 and ios5 sdk. The if condition in the code below returns false and the database closes.

In the console the following message is displayed.

[71280:5303] Failed at Prepare Statement in NumberOfOrders. Reason out of memory
2011-12-07 03:14:31.893 Database Closed
2011-12-07 03:14:31.897  ### *** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty  
array
2011-12-07 03:14:31.898 ### *** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty 
array

Kindly help.

//Open Database connection & assign to pointer dbInstance variable
-(void) OpenDatabase { @try {
NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSLog(@"path is %@", path); 
NSString *documentDir = [path objectAtIndex:0];
NSLog(@"doc directory is %@", documentDir);
NSString *dbPath = [documentDir stringByAppendingPathComponent: @"MAKitTutorials.sqlite"];
NSLog(@"dbPath is %@", dbPath);

if (sqlite3_open_v2([dbPath UTF8String], &dbInstance, SQLITE_OPEN_NOMUTEX, NULL) == SQLITE_OK) {
    NSLog(@"Database Open Succeeds");
} else {
    sqlite3_close(dbInstance);
}
} @catch (NSException * e) {
NSLog(@"Failed to open the database. Reason %@",[e reason] );
}
}
//Close Database connection
-(void) CloseDatabase { sqlite3_close(dbInstance);
}
  • 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-05-28T22:09:29+00:00Added an answer on May 28, 2026 at 10:09 pm

    I hit the same problem when tried to use another flag: SQLITE_OPEN_SHAREDCACHE.
    Solved by explicitly adding two flags used by sqlite3_open() call:
    SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE.

    So in your case it’s going to be:

    SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE | SQLITE_OPEN_NOMUTEX.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use System.Data.Sqlite library, and I'm following the documentation about optimizing inserts
I have been trying to use the hibernate dialect for SQLite from http://code.google.com/p/hibernate-sqlite/ in
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
I'm trying to use sqlite in a 'data services' class like below. I keep
I'm trying to use an SQLite database to store some data for my app.
I'm trying to use SQLite's C API to open a database and access some
I'm trying to use sqlite as database for a symbian app but I can't
I am currently trying to use an SQLite database with a DataGridView in C#.
I'm trying to use an in-memory SQLite database to test my data layer which

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.