2

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

Hensembryan
  • 1,067
  • 3
  • 14
  • 31

1 Answers1

4

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);
Hensembryan
  • 1,067
  • 3
  • 14
  • 31