I can't open database after I close it.

Feb 6, 2011 at 2:21 AM

Tell me please how you were able to open a connection when the SQLite database already exist in Isolated Storage.
I tried , it worked when I created database, but not after I close it.
Thanks for input
Best regards
Adrian Dibu

Apr 8, 2011 at 6:11 PM

Hey there, 

See my explanation given in StackOverflow.


Apr 29, 2011 at 10:14 AM

I performed updates given in :

- http://wp7sqlite.codeplex.com/discussions/244820

- http://stackoverflow.com/questions/5594661/windows-phone-7-sqlite/5595688#5595688

But it doesn't work. I have an SqliteSyntaxException (unable to open database file) :

SqliteConnection connection = new SqliteConnection("Version=3,uri=file:" + DB_NAME);

SqliteCommand stmt = connection.CreateCommand();
stmt.CommandText = "CREATE TABLE TestObject1 ( [oid] VARCHAR(100), [test] VARCHAR(100) );";

stmt.CommandText = "DROP TABLE TestObject1;";


SqliteConnection connection2 = new SqliteConnection("Version=3,uri=file:" + DB_NAME);

SqliteCommand stmt2 = connection2.CreateCommand();
stmt2.CommandText = "CREATE TABLE TestObject1 ( [oid] VARCHAR(100), [test] VARCHAR(100) );";
stmt2.ExecuteNonQuery(); // Crash here : SqliteSyntaxException: unable to open database file

stmt2.CommandText = "DROP TABLE TestObject1;";


What is wrong ?

(Sorry for my very bad english, i'm french)

May 7, 2011 at 11:53 AM

i have exactly the same problem bbillet

May 9, 2011 at 11:35 AM

Hey guys,

I'll try and take a look at this later on tonight or tomorrow. Sorry for the delay in repsonding.



May 24, 2011 at 6:07 PM

Hi there,

any news to this problem?
I got the same error. The first query works fine, all other queries throw this error.

For example there is a button which calls a method to write data from a dictionary to the db.First call / button click works fine, second call throws the error at

cmd.Transaction = conn.BeginTransaction();

Another error I get within a while-loop where the program reads the data from the db via SqliteDataReader:

cmd.CommandText = "SELECT * FROM [table]";
using (SqliteDataReader reader = cmd.ExecuteReader())
    while (reader.Read())
        for (int i = 0; i < reader.FieldCount; i++)
            if (reader[i] != null)
                dicData.Add(i.ToString(), reader[i].ToString());                                 
        dicData.Add("name", reader["name"].ToString());
        dicData.Add("vorname", reader["vorname"].ToString());

First iteration of the loop works fine, the second one throws the error "Value does not fall within the expected range." at the first attempt to add data to the dictionary ( dicData.Add("name", reader["name"].ToString()); )

I also tried the two fixes for the wp7sqlite project I found on the web, but theres no difference to the effect.

Would be great if you can get this thing running. I like the sql syntax and don´t want to change to Sterling or something... :)

Thanks in advance