在c#中使用Access 2010数据库
本文关键字:Access 2010 数据库 | 更新日期: 2023-09-27 18:11:32
我目前正在访问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`
您需要更改:
Provider=Microsoft.Jet.OLEDB.4.0
Provider=Microsoft.ACE.OLEDB.12.0
参见:http://www.connectionstrings.com/access-2007#84
您需要Office 2007 - 2007 Office系统驱动程序:数据连接组件
要在客户端不安装Access的情况下使用数据库,还必须使用Engine2010 Access Database
http://www.microsoft.com/download/en/details.aspx?id=13255问候。