MonoTouch & SQLite - Cannot open database after previous successful connections

Posted by Tanis Draven on Stack Overflow See other posts from Stack Overflow or by Tanis Draven
Published on 2012-10-14T15:15:21Z Indexed on 2012/10/14 15:37 UTC
Read the original article Hit count: 225

Filed under:
|
|
|

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.

© Stack Overflow or respective owner

Related posts about c#

Related posts about ios