database Access 2013 的 OleDb 连接字符串是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15634010/
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 08:54:59  来源:igfitidea点击:

What is the OleDb connection string for Access 2013?

databasems-accessvisual-studio-2012connection-stringms-access-2013

提问by wesleylim1993

I am using Visual Studio 2012 to create a Web application that connects to an Access 2013 database with following programming line:

我正在使用 Visual Studio 2012 创建一个 Web 应用程序,该应用程序使用以下编程线连接到 Access 2013 数据库:

string connectionString = "provider=Microsoft.ACE.OLEDB.12.0;" + "data source=" + Page.Server.MapPath("App_Data\db1.accdb");

But it failed to launch it due to the error

但由于错误未能启动它

Microsoft.ACE.OLEDB.12.0 is not found in local machine

在本地机器中找不到 Microsoft.ACE.OLEDB.12.0

What is the correct connection string for Microsoft Access 2013?

Microsoft Access 2013 的正确连接字符串是什么?

回答by Gord Thompson

The machine acting as the web server must have the "Microsoft Access Database Engine 2010" installed. If that machine does not have Access installed on it then you can download the installer for the engine here.

充当 Web 服务器的计算机必须安装了“Microsoft Access Database Engine 2010”。如果那台机器上没有安装 Access,那么您可以在此处下载引擎的安装程序。

Note that the 64-bit installer includes the 64-bit version only; it does not include the 32-bit version (available separately on that same page).

请注意,64位安装程序包括64位版本; 它不包括 32 位版本(在同一页面上单独提供)。

edit...

编辑...

As for the connection string, I just tested the following VBScript on my Access_2013 machine and it worked fine.

至于连接字符串,我刚刚在我的 Access_2013 机器上测试了以下 VBScript,它运行良好。

Option Explicit
Dim con, rst
Set con = CreateObject("ADODB.Connection")
con.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Gord\Desktop\Database1.accdb;Persist Security Info=False;"
Set rst = CreateObject("ADODB.Recordset")
rst.Open "SELECT Col1 FROM Table1", con
Wscript.Echo rst(0).Value
rst.Close
Set rst = Nothing
con.Close
Set con = nothing

I copied the connection string from connectionstrings.com.

我从connectionstrings.com复制了连接字符串。

edit...

编辑...

If you have access to the web server, you can check for the existence of the following two files:

如果您有权访问 Web 服务器,则可以检查以下两个文件是否存在:

C:\Program Files\Common Files\Microsoft Shared\OFFICE14\ACEOLEDB.DLL

C:\Program Files (x86)\Common Files\Microsoft Shared\OFFICE14\ACEOLEDB.DLL

On a 64-bit machine the first file indicates that the 64-bit version of the Access Database Engine is installed. On a 32-bit machine it indicates that the 32-bit version is installed.

在 64 位计算机上,第一个文件指示安装了 64 位版本的 Access 数据库引擎。在 32 位机器上,它表示安装了 32 位版本。

If the second (x86) file exists then you know that the 32-bit version of the Access Database Engine is present on a 64-bit machine.

如果第二个 (x86) 文件存在,则您知道 32 位版本的 Access 数据库引擎存在于 64 位计算机上。

edit re: final comment

编辑回复:最终评论

The problem was indeed related to the "bitness" of the Access Database Engine:

问题确实与 Access 数据库引擎的“位数”有关:

i install "Microsoft Access Database Engine 2010" 64 bit i should install 32bit due to my visual studio is 32bit thanks for the advice

我安装“Microsoft Access Database Engine 2010” 64 位我应该安装 32 位,因为我的 Visual Studio 是 32 位感谢您的建议

回答by Gord Thompson

It depends with the office you have installed, if you have x64 bit office then you must compile the application as a x64 to allow it to run, so if you want it to run on x36 then you must install office x86 to accept, i tried all the solutions above but none worked until when i realised i had office x64bit and so i built the application as x64 and worked.

这取决于您安装的 office,如果您有 x64 位 office,那么您必须将应用程序编译为 x64 以允许它运行,所以如果您希望它在 x36 上运行,那么您必须安装 office x86 才能接受,我试过了上面的所有解决方案都没有奏效,直到我意识到我有 x64 位办公室,所以我将应用程序构建为 x64 并工作。

I also realised that if you put it to any cpu but do not set to prefere 32 bit also works

我也意识到,如果你把它放在任何 cpu 但不设置为首选 32 位也可以

回答by Anis Ben Khiroun

Let the provider to 12.0 it works for ACCESS 2013

让提供程序到 12.0 它适用于 ACCESS 2013

just install these 2 elements:

只需安装这两个元素:

1)Microsoft Access 2013 Runtime: https://www.microsoft.com/en-us/download/details.aspx?id=39358

1)Microsoft Access 2013 运行时:https: //www.microsoft.com/en-us/download/details.aspx?id=39358

then

然后

2)microsoft access database engine 2007: https://www.microsoft.com/en-us/download/details.aspx?id=23734

2) 微软访问数据库引擎 2007: https://www.microsoft.com/en-us/download/details.aspx?id=23734

PS: x86 for 32bits & x64 for 64bits.

PS:32 位 x86 和 64 位 x64。

回答by user3648788

here use this

在这里使用这个

provider=Microsoft.ACE.OLEDB.15.0

提供商=Microsoft.ACE.OLEDB.15.0

this is the connection string for ms access 2013

这是 ms access 2013 的连接字符串