vendredi 22 mai 2015

Error opening sqlite connection

ConnectionStringSettings connectionString = ConfigurationManager.ConnectionStrings["test"];
SQLiteConnection.CreateFile("MyDatabase.sqlite");
var dbFact = DbProviderFactories.GetFactory(connectionString.ProviderName);

using (var conn = dbFact.CreateConnection())
{
    conn.Open(); // Exception gets thrown here
}

Whenever I execute this code I get the following exception : |

An unhandled exception of type 'System.ArgumentException' occurred in System.Data.SQLite.dll

Additional information: Invalid ConnectionString format, cannot parse: string value to split cannot be null

Here's my app.config :

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://ift.tt/1eigFsq -->
  </configSections>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
  </startup>
  <system.data>
    <DbProviderFactories>
      <remove invariant="System.Data.SQLite"/>
      <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data   Provider for SQLite"
      type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
    </DbProviderFactories>
  </system.data>
  <connectionStrings>
    <add name="test" connectionString="Data Source=MyDatabase.sqlite;Version=3" providerName="System.Data.SQLite"/>
  </connectionStrings>
</configuration>

Can you help me with this, thank you advance.

Aucun commentaire:

Enregistrer un commentaire