This project is read-only.

Exception trying to run a query: malformed schema

Mar 4, 2011 at 4:07 PM

Hi,

I've got a SQLite database that comes from the PC and I've been able to open it fine using PC, Mac, and iOS clients.  I've downloaded the file to my WP7 using WebClient:

          IsolatedStorageFileStream isolatedStorageFileStream = App.isolatedStorageFile.CreateFile(App.applicationName + @"\" +filename);
          long fileLength = (long)e.Result.Length;
          byte[] byteArray = new byte[fileLength];
          e.Result.Read(byteArray, 0, byteArray.Length);
          isolatedStorageFileStream.Write(byteArray, 0, byteArray.Length);
          isolatedStorageFileStream.Close();
          isolatedStorageFileStream.Dispose();

Which should put the file correctly into IsolatedStorage.  I know there's a file in the right location because when I attempt to connect to the SQLite database, it finds it fine, but when I attempt to run a query with the following code:

      String connection = String.Format(@"uri=file:{0}/{1}", applicationName, currentDatabase);
      using (SqliteConnection sqlConnection = new SqliteConnection(connection))
      {
        sqlConnection.Open();

        string sqlStatement = "select ID, PARENTID, NAME from MEDIAMAN_CATEGORIES where PARENTID > -1";
        using (SqliteCommand sqlCommand = sqlConnection.CreateCommand())
        {
          sqlCommand.CommandText = sqlStatement;

          using (SqliteDataReader reader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.SequentialAccess))

I get an exception: "malformed database schema (?)"

   at Community.CsharpSqlite.SQLiteClient.SqliteCommand.GetNextStatement(String pzStart, String& pzTail, Vdbe& pStmt)
   at Community.CsharpSqlite.SQLiteClient.SqliteCommand.ExecuteReader(CommandBehavior behavior, Boolean want_results, Int32& rows_affected)
   at Community.CsharpSqlite.SQLiteClient.SqliteCommand.ExecuteReader(CommandBehavior behavior)
   at iMediaMan.App.ReadCategoriesFromDatabase()
   at iMediaMan.MainPage.MainPage_Loaded(Object sender, RoutedEventArgs e)
   at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)
Anyone have any insight as to what could be wrong?  Is there a way to confirm that the SQLite file was saved into IsolatedStorage?  
I know the file is good [on the PC] and I'm assuming that the file is downloaded using WebClient was saved without an issue...