Question

I try use ms access as data provider but it give me exception.

    static void Main(string[] args)
    {
        DataContext dx = new DataContext(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Data\mail.accdb;Persist Security Info=True");
    }

The exception is

System.ArgumentException was unhandled
Message=Keyword not supported: 'provider'.

How could this happen ?

Thanks in advance,

Brian

Was it helpful?

Solution

Okay I Found the solution. It bit tricky

First create oledbconnection with access data provider

IDbConnection connection = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Data\mail.accdb;Persist Security Info=True);

Last pass it to DataContext

DataContext dx = new DataContext(connection);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top