4

I am trying to use the ProviderFactory.CreateConnection() to obtain a SQLite connection. I am getting a System.ArgumentException with the following message:

"Keyword not supported: 'datetimeformat'."

The connection string is:

@"data source=d:\db\Test.db3;Pooling=True;Max Pool Size=10;datetimeformat=Ticks"

In the app.config file I have:

<system.data>
  <DbProviderFactories>
    <remove invariant="System.Data.SQLite"/>
    <add name="SQLite Data Provider" invariant="System.Data.SQLite"
       support="3F" description=".Net Framework Data Provider for SQLite"
         type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
  </DbProviderFactories>
</system.data>

The connection string works when I instantiate a SQLiteConnection instance. It fails using the ProviderFactory. Any suggestions on how I can resolve this?

demongolem
  • 9,474
  • 36
  • 90
  • 105
Elan
  • 6,084
  • 12
  • 64
  • 84
  • "ProviderFactory" is my own property accessor to DbProviderFactories.GetFactory("...") – Elan Feb 25 '11 at 00:36

1 Answers1

2

It turned out, that I forgot to execute the following line of code:

DbProviderFactory providerFactory =
    DbProviderFactories.GetFactory("System.Data.SqlClient");

And the ensuing code worked then as expected without exception:

IDbConnection conn = providerFactory.CreateConnection();
Elan
  • 6,084
  • 12
  • 64
  • 84