visual-studio Microsoft.ACE.OLEDB.12.0 提供程序未注册

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

Microsoft.ACE.OLEDB.12.0 provider is not registered

visual-studioms-accessado.netoledb

提问by Azim

I have a Visual Studio 2008 solution with two projects (a Word-Template project and a VB.Net console application for testing). Both projects reference a database project which opens a connection to an MS-Access 2007 database file and have references to System.Data.OleDb. In the database project I have a function which retrieves a data table as follows

我有一个包含两个项目的 Visual Studio 2008 解决方案(一个 Word-Template 项目和一个用于测试的 VB.Net 控制台应用程序)。这两个项目都引用了一个数据库项目,该项目打开了到 MS-Access 2007 数据库文件的连接并引用了 System.Data.OleDb。在数据库项目中,我有一个检索数据表的函数,如下所示

 private class AdminDatabase
   ' stores the connection string which is set in the New() method
   dim strAdminConnection as string

   public sub New()
   ...
   adminName = dlgopen.FileName
   conAdminDB = New OleDbConnection
   conAdminDB.ConnectionString = "Data Source='" + adminName + "';" + _
       "Provider=Microsoft.ACE.OLEDB.12.0"

   ' store the connection string in strAdminConnection
   strAdminConnection = conAdminDB.ConnectionString.ToString()
   My.Settings.SetUserOverride("AdminConnectionString", strAdminConnection)
   ...
   End Sub

   ' retrieves data from the database
   Public Function getDataTable(ByVal sqlStatement As String) As DataTable
        Dim ds As New DataSet
        Dim dt As New DataTable
        Dim da As New OleDbDataAdapter
        Dim localCon As New OleDbConnection


        localCon.ConnectionString = strAdminConnection

        Using localCon
            Dim command As OleDbCommand = localCon.CreateCommand()
            command.CommandText = sqlStatement
            localCon.Open()
            da.SelectCommand = command
            da.Fill(dt)
            getDataTable = dt
        End Using

    End Function
End Class

When I call this function from my Word 2007 Template project everything works fine; no errors. But when I run it from the console application it throws the following exception

当我从 Word 2007 模板项目调用此函数时,一切正常;没有错误。但是当我从控制台应用程序运行它时,它会抛出以下异常

ex = {"The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine."}

ex = {"'Microsoft.ACE.OLEDB.12.0' 提供程序未在本地计算机上注册。"}

Both projects have the same reference and the console application did work when I first wrote it (a while ago) but now it has stopped work. I must be missing something but I don't know what. Any ideas?

这两个项目具有相同的引用,并且控制台应用程序在我第一次编写时(不久前)确实可以工作,但现在它已停止工作。我一定错过了一些东西,但我不知道是什么。有任何想法吗?

采纳答案by Matt

I have a visual Basic program with Visual Studio 2008 that uses an Access 2007 database and was receiving the same error. I found some threads that advised changing the advanced compile configuration to x86 found in the programs properties if you're running a 64 bit system. So far I haven't had any problems with my program since.

我有一个带有 Visual Studio 2008 的 Visual Basic 程序,它使用 Access 2007 数据库并收到相同的错误。如果您运行的是 64 位系统,我发现一些线程建议将高级编译配置更改为程序属性中的 x86。到目前为止,我的程序没有遇到任何问题。

回答by Matt

Basically, if you're on a 64-bit machine, IIS 7 is not (by default) serving 32-bit apps, which the database engine operates on. So here is exactly what you do:

基本上,如果您使用的是 64 位计算机,则 IIS 7(默认情况下)不会为数据库引擎运行的 32 位应用程序提供服务。所以这正是你要做的:

1) ensure that the 2007 database engine is installed, this can be downloaded at: http://www.microsoft.com/downloads/details.aspx?FamilyID=7554F536-8C28-4598-9B72-EF94E038C891&displaylang=en

1) 确保安装了 2007 数据库引擎,可在以下网址下载:http: //www.microsoft.com/downloads/details.aspx?FamilyID=7554F536-8C28-4598-9B72-EF94E038C891&displaylang=en

2) open IIS7 manager, and open the Application Pools area. On the right sidebar, you will see an option that says "Set application pool defaults". Click it, and a window will pop up with the options.

2)打开IIS7管理器,打开Application Pools区域。在右侧边栏上,您会看到一个选项,上面写着“设置应用程序池默认值”。单击它,将弹出一个包含选项的窗口。

3) the second field down, which says 'Enable 32-bit applications' is probably set to FALSE by default. Simply click where it says 'false' to change it to 'true'.

3) 向下的第二个字段,其中显示“启用 32 位应用程序”可能默认设置为 FALSE。只需单击显示“假”的位置即可将其更改为“真”。

4) Restart your app pool (you can do this by hitting RECYCLE instead of STOP then START, which will also work).

4) 重新启动您的应用程序池(您可以通过点击 RECYCLE 而不是 STOP 然后点击 START 来实现,这也可以)。

5) done, and your error message will go away.

5) 完成,您的错误信息将消失。

回答by Joel Lucsy

Are you running a 64 bit system with the database running 32 bit but the console running 64 bit? There are no MS Access drivers that run 64 bit and would report an error identical to the one your reported.

您是否运行 64 位系统,数据库运行 32 位,但控制台运行 64 位?没有运行 64 位的 MS Access 驱动程序会报告与您报告的错误相同的错误。

回答by Pescadore



Solution:

解决方案:

That's it! Thanks Arjun Paudel for the link. Here's the solution as found on XNA Creator's Club Online. It's by Stephen Styrchak.

而已!感谢 Arjun Paudel 提供链接。这是在 XNA Creator's Club Online 上找到的解决方案。这是斯蒂芬·斯蒂尔查克 (Stephen Styrchak) 的作品。

The following error suggests me to believe that you are compiling for 64bit:

以下错误表明我相信您正在为 64 位编译:

The 'Microsoft .ACE.OELDB.12.0' provider is not registered on the local machine

“Microsoft .ACE.OELDB.12.0”提供程序未在本地计算机上注册

I dont have express edition but are following steps valid in 2008 express?

我没有速成版,但以下步骤在 2008 速成版中是否有效?

http://forums.xna.com/forums/t/4377.aspx#22601

http://forums.xna.com/forums/t/4377.aspx#22601

http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/ed374d4f-5677-41cb-bfe0-198e68810805/?prof=required
- Arjun Paudel

http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/ed374d4f-5677-41cb-bfe0-198e68810805/?prof=required
- Arjun Paudel



In VC# Express, this property is missing, but you can still create an x86 configuration if you know where to look.

在 中VC# Express,缺少此属性,但如果您知道在哪里查找,您仍然可以创建 x86 配置。

It looks like a long list of steps, but once you know where these things are it's a lot easier. Anyone who only has VC# Expresswill probably find this useful. Once you know about Configuration Manager, it'll be much more intuitive the next time.

它看起来像一长串步骤,但一旦你知道这些东西在哪里,事情就容易多了。任何只有拥有的VC# Express人可能会发现这很有用。一旦你知道了Configuration Manager,下次它就会更加直观。

1.In VC# Express 2005, go to Tools -> Options.
2.In the bottom-left corner of the Options dialog, check the box that says, "Show all settings".
3.In the tree-view on the left hand side, select "Projects and Solutions".
4.In the options on the right, check the box that says, "Show advanced build configuraions."
5.Click OK.
6.Go to Build -> Configuration Manager...
7.In the Platform column next to your project, click the combobox and select "<New...>".
8.In the "New platform" setting, choose "x86".
9.Click OK.
10.Click Close.
There, now you have an x86 configuration! Easy as pie! :-)

1.在 VC# Express 2005 中,转到Tools -> Options.
2.在选项对话框的左下角,选中显示的框"Show all settings"
3.在左侧的树视图中,选择"Projects and Solutions"
4.在右侧的选项中,选中显示"Show advanced build configuraions."
5.Click的框OK
6.转到Build -> Configuration Manager...
7.在项目旁边的平台列中,单击组合框并选择"<New...>"
8.在"New platform" setting, choose "x86".
9. 单击OK
10. 单击Close
好了,现在您有了 x86 配置!易如反掌!:-)

I also recommend using Configuration Managerto delete the Any CPU platform. You really don't want that if you ever have depedencies on 32-bit native DLLs (even indirect dependencies).

我还建议使用Configuration Manager删除 Any CPU 平台。如果您曾经依赖 32 位本机 DLL(甚至是间接依赖关系),那么您真的不希望出现这种情况。

Stephen Styrchak | XNA Game Studio Developer http://forums.xna.com/forums/p/4377/22601.aspx#22601

斯蒂芬·斯蒂尔查克 | XNA 游戏工作室开发者 http://forums.xna.com/forums/p/4377/22601.aspx#22601



回答by Veli Gebrev

I thought I'd chime in because I found this question when facing a slightly different context of the problem and thought it might help other tormented souls in the future:

我想我会插话,因为我在面对稍微不同的问题时发现了这个问题,并认为它可能会在未来帮助其他受折磨的灵魂:

I had an ASP.NET app hosted on IIS 7.0 running on Windows Server 2008 64-bit.

我在 64 位 Windows Server 2008 上运行的 IIS 7.0 上托管了一个 ASP.NET 应用程序。

Since IIS is in control of the process bitness, the solution in my case was to set the Enable32bitAppOnWin64 setting to true: http://blogs.msdn.com/vijaysk/archive/2009/03/06/iis-7-tip-2-you-can-now-run-32-bit-and-64-bit-applications-on-the-same-server.aspx

由于 IIS 控制进程位数,因此我的解决方案是将 Enable32bitAppOnWin64 设置设置为 true:http: //blogs.msdn.com/vijaysk/archive/2009/03/06/iis-7-tip- 2-you-can-now-run-32-bit-and-64-bit-applications-on-the-same-server.aspx

It works slightly differently in IIS 6.0 (You cannot set Enable32bitAppOnWin64 at application-pool level) http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/0aafb9a0-1b1c-4a39-ac9a-994adc902485.mspx?mfr=true

它在 IIS 6.0 中的工作方式略有不同(您不能在应用程序池级别设置 Enable32bitAppOnWin64) http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/0aafb9a0-1b1c-4a39-ac9a-994adc902485.mspx?制造商=真

回答by xdxavier

I'm having same problem. I try to install office 2010 64bit on windows 7 64 bit and then install 2007 Office System Driver : Data Connectivity Components.

我有同样的问题。我尝试在 windows 7 64 位上安装 office 2010 64bit,然后安装 2007 Office System Driver:Data Connectivity Components。

after that, visual studio 2008 can opens a connection to an MS-Access 2007 database file.

之后,visual studio 2008 可以打开与 MS-Access 2007 数据库文件的连接。

回答by TechSpud

See my post on a similar Stack Exchange thread https://stackoverflow.com/a/21455677/1368849

请参阅我在类似 Stack Exchange 线程上的帖子https://stackoverflow.com/a/21455677/1368849

I had version 15, not 12 installed, which I found out by running this PowerShell code...

我安装了 15 版,而不是 12 版,这是我通过运行此 PowerShell 代码发现的...

(New-Object system.data.oledb.oledbenumerator).GetElements() | select SOURCES_NAME, SOURCES_DESCRIPTION

...which gave me this result (I've removed other data sources for brevity)...

...这给了我这个结果(为简洁起见,我删除了其他数据源)...

SOURCES_NAME              SOURCES_DESCRIPTION                                                                       
------------              -------------------                                                                       
Microsoft.ACE.OLEDB.15.0  Microsoft Office 15.0 Access Database Engine OLE DB Provider

回答by Merav Kochavi

I am assuming that if you are running a 64 bit system with a 32 bit database and trying to run a 64 bit console, the following packages need to be installed on the machine.

我假设如果您正在运行具有 32 位数据库的 64 位系统并尝试运行 64 位控制台,则需要在机器上安装以下软件包。

  1. Install the Microsoft Access Database Engine 2010 x86 Redistributable, this installation is available at: http://www.microsoft.com/download/en/details.aspx?id=13255.
  2. Data Connectivity Components of Office 2007, this installation is available at: http://www.microsoft.com/download/en/confirmation.aspx?id=23734.
  3. Microsoft Access Database Engine 2010 x64 Redistributable. You will need to download the package locally and run it with a passive flag. You can download the installation here: http://www.microsoft.com/en-us/download/details.aspx?id=13255Installing using the command prompt with the '/passive' flag. In the command prompt run the following command: 'AccessDatabaseEngine_x64.exe /passive'
  1. 安装 Microsoft Access 数据库引擎 2010 x86 Redistributable,此安装位于:http: //www.microsoft.com/download/en/details.aspx?id=13255
  2. Office 2007 的数据连接组件,此安装位于:http: //www.microsoft.com/download/en/confirmation.aspx?id=23734
  3. Microsoft Access 数据库引擎 2010 x64 可再发行组件。您需要在本地下载软件包并使用被动标志运行它。您可以在此处下载安装:http: //www.microsoft.com/en-us/download/details.aspx?id=13255 使用带有“/passive”标志的命令提示符进行安装。在命令提示符下运行以下命令:'AccessDatabaseEngine_x64.exe /passive'

Note: The order seems to matter - so if you have anything installed already, uninstall and follow the steps above.

注意:顺序似乎很重要 - 所以如果您已经安装了任何东西,请卸载并按照上述步骤操作。

回答by jazzwhistle

I've got the same error on a fully updated Windows Vista Family 64bit with a .NET application that I've compiled to 32 bit only - the program is installed in the programx86 folder on 64 bit machines. It fails with this error message even with 2007 access database provider installed, with/wiothout the SP2 of the same installed, IIS installed and app pool set for 32bit app support... yes I've tried every solution everywhere and still no success.

我在带有 .NET 应用程序的完全更新的 64 位 Windows Vista 家族上遇到了同样的错误,我仅将其编译为 32 位 - 该程序安装在 64 位机器上的 programx86 文件夹中。即使安装了 2007 访问数据库提供程序,安装/没有安装相同的 SP2,安装 IIS 和应用程序池设置为 32 位应用程序支持,它也会失败并显示此错误消息......是的,我已经尝试了所有解决方案,但仍然没有成功。

I switched my app to ACE OLE DB.12.0 because JET4.0 was failing on 64bit machines - and it's no better :-/ The most promising thread I've found was this:

我将我的应用程序切换到 ACE OLE DB.12.0,因为 JET4.0 在 64 位机器上失败了 - 它也没有更好:-/ 我发现的最有前途的线程是这样的:

http://ellisweb.net/2010/01/connecting-to-excel-and-access-files-using-net-on-a-64-bit-server/

http://ellisweb.net/2010/01/connecting-to-excel-and-access-files-using-net-on-a-64-bit-server/

but when you try to install the 64 bit "2010 Office System Driver Beta: Data Connectivity Components" it tells you that you can't install the 64 bit version without uninstalling all 32bit office applications... and installing the 32 bit version of 2010 Office System Driver Beta: Data Connectivity Components doesn't solve the initial problem, even with "Microsoft.ACE.OLEDB.12.0" as provider instead of "Microsoft.ACE.OLEDB.14.0" which that page (and others) recommend.

但是当您尝试安装 64 位“2010 Office System Driver Beta: Data Connectivity Components”时,它会告诉您,如果不卸载所有 32 位办公应用程序,就无法安装 64 位版本……并安装 2010 的 32 位版本Office System Driver Beta:Data Connectivity Components 无法解决最初的问题,即使使用“Microsoft.ACE.OLEDB.12.0”作为提供程序,而不是该页面(和其他页面)推荐的“Microsoft.ACE.OLEDB.14.0”。

My next attempt will be to follow this post:

我的下一次尝试是关注这篇文章:

The issue is due to the wrong flavor of OLEDB32.DLL and OLEDB32r.DLL being registered on the server. If the 64 bit versions are registered, they need to be unregistered, and then the 32 bit versions registered instead. To fix this, unregister the versions located in %Program Files%/Common Files/System/OLE DB. Then register the versions at the same path but in the %Program Files (x86)% directory.

该问题是由于在服务器上注册的 OLEDB32.DLL 和 OLEDB32r.DLL 的风格错误所致。如果注册了 64 位版本,则需要取消注册,然后注册 32 位版本。要解决此问题,请取消注册位于 %Program Files%/Common Files/System/OLE DB 中的版本。然后在同一路径但在 %Program Files (x86)% 目录中注册版本。

Has anyone else had so much trouble with both JET4.0 and OLEDB ACE providers on 64 bit machines? Has anyone found a solution if none of the others work?

有没有其他人在 64 位机器上对 JET4.0 和 OLEDB ACE 提供程序有这么多麻烦?如果其他人都不起作用,有没有人找到解决方案?