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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:33:34+00:00 2026-06-13T00:33:34+00:00

I am having difficulty in reading data from my SQLite database from MonoTouch. I

  • 0

I am having difficulty in reading data from my SQLite database from MonoTouch.

I can read and write without any difficulty for the first few screens and then suddenly I am unable to create any further connections with the error:

Mono.Data.Sqlite.SqliteException: Unable to open the database file   
at Mono.Data.Sqlite.SQLite3.Open (System.String strFilename, SQLiteOpenFlagsEnum flags, Int32 maxPoolSize, Boolean usePool) [0x0007e] in /Developer/MonoTouch/Source/mono/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLite3.cs:136    
at Mono.Data.Sqlite.SqliteConnection.Open () [0x002aa] in /Developer/MonoTouch/Source/mono/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLiteConnection.cs:888 

I ensure that i dispose and close every connection each time i use it but still i have this problem. For example:

var mySqlConn = new SqliteConnection(GlobalVars.connectionString);
mySqlConn.Open();
SqliteCommand mySqlCommand = new SqliteCommand(SQL, mySqlConn);
mySqlCommand.ExecuteNonQuery();
mySqlConn.Close();
mySqlCommand.Dispose();
mySqlConn.Dispose();

I’m guessing that I’m not closing the connections correctly. Any help would be greatly appreciated.

  • 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-13T00:33:35+00:00Added an answer on June 13, 2026 at 12:33 am

    I’m pretty sure you guess is right. However it’s pretty hard to guess what went wrong (e.g. what’s defined in your connectionString will affect how Sqlite is initialized and will work).

    From your example you seem to be disposing the SqliteConnection correctly but things could still go wrong. E.g. if some code throws an exception (and you catch them somewhere) then the Dispose call might never be called. It would be safer to do something like:

    using (var mySqlConn = new SqliteConnection(GlobalVars.connectionString) {
        mySqlConn.Open();
        using (SqliteCommand mySqlCommand = new SqliteCommand(SQL, mySqlConn)) {
            mySqlCommand.ExecuteNonQuery();
            // work with the data
        }
        mySqlConn.Close();
    }
    

    That would ensure that the automagically finally clauses will dispose of the instance you create.

    Also you might want to consider reusing your (first) connection instance, e.g. opening it once and re-use it everywhere in your application. OTOH you need to be aware of threading in this case (by default, you can change it, each connection is only safe to use on the thread that has created it).

    Reusing could help your app performance but it also does not really fix your issue (but it might hide it). So I suggest you try to debug this first:

    Using MonoDevelop you can set a breakpoint on line #136 on the /Developer/MonoTouch/Source/mono/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLite3.cs file (which is included with your MonoTouch installation) to see the actual n error code (before it gets translated to a string).

    You can also set breakpoints on the dispose code to ensure it gets executed (and does not return errors). The number of connection creations and disposals should match. If not then use the Call Stack to see who’s opening without closing.

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

Sidebar

Related Questions

I'm using Amazon's RDS, and I'm having difficulty reading utf data from the DB.
I'm having a problem reading and processing data from my server. I've spent hours
I am parsing an Excel file and am having difficulty reading in the value
Im having difficulty trying to design a database structure for the following scenario: My
All, I'm exploring the feasibility of reading data from a local Excel file in
I'm having difficulty figuring out how to make the jump from a Scala high-order
I'm reading this book: http://eloquentjavascript.net/ which I think is brilliant. However I'm having difficulty
I am having difficulty outputting data in UTF-8 format. I have a test case
I am having great difficulty reading the API for named scopes. Each bid has
update: added LinkedList.h and SymbolTable.h So I'm having difficulty with a programming assignment from

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.