I'm trying to test PetaPOCO with MS Access database.
Connection string in web.config
<add name="ConString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=Data.mdb; Persist Security Info=False" providerName="System.Data.Oledb" />
Accessing MS Access database-
var db = new PetaPoco.Database("ConString"); //throws exception here
var rows = db.Query<Model>("SELECT * FROM Table");
Exception thrown-
"Could not match `System.Data.Oledb` to a provider.Parameter name: providerName"
Is there any way to do it? If yes, how?
Starting with PetaPoco version 5.1.127 or later, MS Access support is backed in and no custom DB provider is required.
Sample config file
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<clear />
<add name="msaccess" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|Databases\MSAccess\petapoco.accdb" providerName="OleDb"/>
</connectionStrings>
</configuration>
Fluent configuration
var builder = DatabaseConfiguration.Build().UsingConnectionName("MyConnection");
var db = builder.Create();
Constructor configuration
var db = new Database("MyConnection");