Using an Access 2010 Database in C #

I am currently accessing the 2010 access database in C # and it cannot open the database because it does not seem to have the correct driver when I used .mdb, it worked, but now when I use. accdb does not seem to want to open the database. Here is the introductory code. I was wondering if there is anything that you could help me?

public void openDatabase(string dbname) { //dataBaseName = dbname; dataBaseName = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=houses.accdb"; //Defines the location of the database and its type. connection = new OleDbConnection(dataBaseName); //Creates a new OleDbConnection using the data from dataBase. connection.Open(); //Opens the TCP/IP connection. }`enter code here` 
+4
source share
3 answers

You need to change:

 Provider=Microsoft.Jet.OLEDB.4.0 

For

 Provider=Microsoft.ACE.OLEDB.12.0 

See also: http://www.connectionstrings.com/access-2007#84

+4
source
0
source

to use a database without access installed on the client, you must also use Database2010 Access Database

http://www.microsoft.com/download/en/details.aspx?id=13255

Sincerely.

0
source

All Articles