Ben Wilson
Ben Wilson

Reputation: 3137

Using Access 2010 database in c#

I am currently accessing a access 2010 database in c# and its unable to open the database as it doesn't seem to have the correct driver when I was using a .mdb this worked, but now since I'm using a .accdb it doesn't seem to want to open the database. Here's the opening code. I was wondering if there was anything you could help me with?

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`

Upvotes: 4

Views: 11649

Answers (3)

Carmelo La Monica
Carmelo La Monica

Reputation: 765

to use the datbase without Access installed on a client you must also Engine2010 Access Database

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

Regards.

Upvotes: 0

James
James

Reputation: 82136

You need the driver for Office 2007 - 2007 Office System Driver: Data Connectivity Components

Upvotes: 0

Fionnuala
Fionnuala

Reputation: 91376

You need to change:

Provider=Microsoft.Jet.OLEDB.4.0

To

Provider=Microsoft.ACE.OLEDB.12.0

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

Upvotes: 4

Related Questions