vba Access 2010 的连接字符串

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7144062/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 11:47:48  来源:igfitidea点击:

Connection string for Access 2010

ms-accessvba

提问by Nagendra

I want to connect to the access 2010 database from excel.I am using VBA.I wrote the connection string as

我想从 excel 连接到 access 2010 数据库。我正在使用 VBA。我将连接字符串写为

Public objCon As New ADODB.Connection

objCon.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & ActiveWorkbook.Path & _
            "\asset_database.accdb;ACE OLEDB:Database Password=password;"

But it is giving the error "could not find installable ISAM".What is this error?

但它给出了错误“找不到可安装的 ISAM”。这是什么错误?

回答by Fionnuala

Oddly enough, it is Jet OLEDB Password, not ACE:

奇怪的是,它是 Jet OLEDB 密码,而不是 ACE:

objCon.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & ActiveWorkbook.Path _
   & "\asset_database.accdb;Jet OLEDB:Database Password=password;"

See: http://www.connectionstrings.com/access-2007

请参阅:http: //www.connectionstrings.com/access-2007

回答by Banjoe

Try "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & ActiveWorkbook.Path & "\asset_database.accdb;JET OLEDB:Database Password=password;"

试试“Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & ActiveWorkbook.Path & "\asset_database.accdb;JET OLEDB:Database Password=password;”

回答by sigil

If you have Access installed, or you install the Access Database Engine on the workstation that has the Excel spreadsheet open, then you don't need to create an OLEDB connection; you can just open a database object as follows:

如果您安装了 Access,或者您在打开 Excel 电子表格的工作站上安装了 Access 数据库引擎,则不需要创建 OLEDB 连接;您可以按如下方式打开一个数据库对象:

dim db as database

set db=opendatabase("c:\db path\my db.accdb")