2011-10-17 116 views
4

我目前正在访问一个访问2010年数据库在c#中,它无法打开数据库,因为它似乎没有正确的驱动程序,当我使用.mdb这工作,但现在我正在使用.accdb,它似乎不想打开数据库。这是开放代码。我想知道你有什么可以帮助我吗?在c中使用Access 2010数据库#

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` 

回答