I can't open database

Feb 6, 2011 at 3:03 AM
Edited Feb 6, 2011 at 3:13 AM

Hi,

To be more specific

To make it work I commented line 6040 in btree_c.cs

// Debug.Assert( sz == cellSize( pPage, idx ) );

 private void PhoneApplicationPage_Loaded(object sender, RoutedEventArg    {    

isf = IsolatedStorageFile.GetUserStoreForApplication();

     if (isf.FileExists("CustomerDB.sqlite") == true)

         {MessageBox.Show("Exist", "CustomerDB.sqlite", MessageBoxButton.OK);

             LoadDB2(); }

         else { MessageBox.Show("Don't exist", "CustomerDB.sqlite",              MessageBoxButton.OK);

             LoadDB1(); }}

private void LoadDB1(){if (conn != null)

         { MessageBox.Show("conn in LoadDB1", "Not null", MessageBoxButton.OK);}

else{MessageBox.Show("conn in LoadDB1 ", "Null Open Database", MessageBoxButton.OK);

       conn = new SqliteConnection("Version=3,uri=file:CustomerDB.sqlite");

       conn.Open();}}

 

private void LoadDB2(){if (conn != null){

     MessageBox.Show("conn in LoadDB2", "Not null", MessageBoxButton.OK);}

conn.Open();

     else{MessageBox.Show("conn in LoadDB2 ", "Null Open Database", MessageBoxButton.OK);

  conn = new SqliteConnection("Version=3,uri=file:CustomerDB.sqlite");

conn.Open();

!!!!!!!!// Here I am kicked out because conn can’t open databas

     }

Feb 17, 2011 at 8:13 AM

Hi!

Do you solve your problem? I have the same issues.

Feb 17, 2011 at 10:25 PM

I think I've just found the solution.

There is a HandleTracker which doesn't get cleared then SqliteConnection is closing by calling method Close().

All you have to do is just add one line of code to the end of the method Community.CsharpSqlite.SQLiteClient.Close()

public void Close ()
{
    if (state != ConnectionState.Open) {
        return;
    }
			
    state = ConnectionState.Closed;
		
    if (Version == 3)
    //Sqlite3.sqlite3_close()
        Sqlite3.sqlite3_close (sqlite_handle2);
    //else 
        //Sqlite.sqlite_close (sqlite_handle);
    sqlite_handle = IntPtr.Zero;

    //!!add this!!
    //Have to clear the array of open file's handles
    FileStream.HandleTracker.Clear();
}

 

Apr 8, 2011 at 1:51 PM

Thanks. That line was the difference between me needing to spend an additional couple of weeks coding for a different database.

May 8, 2011 at 11:24 AM
Edited May 8, 2011 at 11:40 AM
imageofyou wrote:

I think I've just found the solution.

There is a HandleTracker which doesn't get cleared then SqliteConnection is closing by calling method Close().

All you have to do is just add one line of code to the end of the method Community.CsharpSqlite.SQLiteClient.Close()

 

public void Close ()
{
    if (state != ConnectionState.Open) {
        return;
    }
			
    state = ConnectionState.Closed;
		
    if (Version == 3)
    //Sqlite3.sqlite3_close()
        Sqlite3.sqlite3_close (sqlite_handle2);
    //else 
        //Sqlite.sqlite_close (sqlite_handle);
    sqlite_handle = IntPtr.Zero;

    //!!add this!!
    //Have to clear the array of open file's handles
    FileStream.HandleTracker.Clear();
}

 

 

but how can i access the source, when i download the package from wp7sqlite.codeplex.com it only contains the dlls

 

EDIT: found it -.- (i'm new on codeplex), THx it fixed my connection problem,too