C# “Microsoft.ACE.OLEDB.12.0”提供程序未在本地计算机上注册。
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11179905/
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
The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.
提问by Kyabroudi
every thing work fine locally but this error occurs when I publish it:
一切都在本地正常运行,但是当我发布它时会发生此错误:
The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.
and stack trace
和堆栈跟踪
[InvalidOperationException: The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.]
System.Data.OleDb.OleDbServicesWrapper.GetDataSource(OleDbConnectionString constr, DataSourceWrapper& datasrcWrapper) +1027372
System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection) +337
System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) +86
System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup) +31
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +76
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +126
System.Data.OleDb.OleDbConnection.Open() +43
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +123
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +319
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +92
System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1618
System.Web.UI.WebControls.ListControl.OnDataBinding(EventArgs e) +97
System.Web.UI.WebControls.ListControl.PerformSelect() +34
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +74
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +66
System.Web.UI.WebControls.ListControl.OnPreRender(EventArgs e) +29
System.Web.UI.Control.PreRenderRecursiveInternal() +103
System.Web.UI.Control.PreRenderRecursiveInternal() +175
System.Web.UI.Control.PreRenderRecursiveInternal() +175
System.Web.UI.Control.PreRenderRecursiveInternal() +175
System.Web.UI.Control.PreRenderRecursiveInternal() +175
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2496
I am using MS access 2007 database and this my connection string within web.config
我正在使用 MS access 2007 数据库,这是我在 web.config 中的连接字符串
<add name="ConnectionString" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\OmanLegalDB.accdb;Persist Security Info=True" providerName="System.Data.OleDb"/>
any suggestions for this problem
对此问题的任何建议
采纳答案by Marcel N.
For version 12.0 you need to install MDAC 2010 from here.
对于 12.0 版,您需要从这里安装 MDAC 2010 。
This has to be done on the server where you publish your application.
You need to install the x86 version if the target machine is 32 bit or the x64 version if the target machine is 64 bit and your application is built with configuration Any CPU.
这必须在您发布应用程序的服务器上完成。如果目标机器是 32 位,则需要安装 x86 版本;如果目标机器是 64 位并且您的应用程序是使用配置构建的,则需要安装 x64 版本Any CPU。
回答by AvkashChauhan
Your connection string is right so this error could be caused by following reason:
您的连接字符串是正确的,因此此错误可能由以下原因引起:
- If your Office is 32 bit on a 64bit machine and MDAC driver installed is 64bit. In this case you would need to install 32bit MDAC driver to match 32bit Office binaries.
- 如果您的 Office 在 64 位计算机上是 32 位,并且安装的 MDAC 驱动程序是 64 位。在这种情况下,您需要安装 32 位 MDAC 驱动程序以匹配 32 位 Office 二进制文件。
This posthas detailed info on how to troubleshoot it.
这篇文章提供了有关如何对其进行故障排除的详细信息。

