在c#中使用Access 2010数据库

时间:2021-02-08 15:38:46

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?

我目前正在访问c#中的access 2010数据库并且无法打开数据库,因为当我使用.mdb时它似乎没有正确的驱动程序,但是现在因为我使用的是.accdb它没有好像想要打开数据库。这是开场代码。我想知道你能帮我什么吗?

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`

3 个解决方案

#1


4  

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

另见:http://www.connectionstrings.com/access-2007#84

#2


0  

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

您需要Office 2007 - 2007 Office System驱动程序:数据连接组件的驱动程序

#3


0  

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

要在客户端上安装没有Access的数据库,您还必须使用Engine2010 Access Database

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

Regards.

#1


4  

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

另见:http://www.connectionstrings.com/access-2007#84

#2


0  

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

您需要Office 2007 - 2007 Office System驱动程序:数据连接组件的驱动程序

#3


0  

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

要在客户端上安装没有Access的数据库,您还必须使用Engine2010 Access Database

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

Regards.