jeudi 28 mai 2015

Open Android db from C#: "Only SQLite Version 3 is supported at this time" NotSupportedException

I am trying to connect and read from an android (sqlite) database, from a C# application (VS2010 Pro). I've tried different versions of System.Data.SQLite.dll (for .NET 3.5, on x86 / .NET 4.0 on x64). Still I can't go over this exception:

*System.NotSupportedException was unhandled
 HResult=-2146233067
 Message=Only SQLite Version 3 is supported at this time
 Source=System.Data.SQLite
 StackTrace:
   at System.Data.SQLite.SQLiteConnection.Open()
   at ConsoleApplication1.Program.Main(String[] args) in   C:\Users\lucian.teodorescu\documents\visual studio 2010\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs:line 18
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

InnerException:*

My code is:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Data.SQLite;
    using System.Data;

    namespace ConsoleApplication1
    {
    class Program
     { 
      static void Main(string[] args)
      {
        SQLiteConnection m_dbConnection;
        m_dbConnection = new SQLiteConnection("Data Source=\\\\192.xxx.xx.xxx:5555\\data\\data\\MyApp\\sqlite_db\\AUTOMATICTEST\\W1579_W2PR_QA_R13.db;Version=0;");
      //m_dbConnection = new SQLiteConnection("Data  Source=L:\\Lucian\\workspace\\W1579_W2PR_QA_R13.db;Version=0;");
        m_dbConnection.Open();
        string sql = "select * from SSS_CUSTOMER WHERE customer_number01 = 90685";
        SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection);
        Console.WriteLine(sql);
       }
     }
    }

Looking into this source, on line 823, I find this, but I still don't get it:

    if (Convert.ToInt32(FindKey(opts, "Version", "3"), CultureInfo.InvariantCulture) != 3)
    throw new NotSupportedException("Only SQLite Version 3 is supported at this time");

What has to be done to overcame this exception?

Aucun commentaire:

Enregistrer un commentaire