如何摆脱异常";';Microsoft.ACE.OLEDB.12.0';提供者没有在本地机器上注册”

本文关键字:机器 注册 quot 异常 何摆脱 Microsoft ACE OLEDB 提供者 | 更新日期: 2023-09-27 17:57:30

我正在Win 7计算机上使用VS2010在.NET 4.0框架上运行ASP.NET C#应用程序。在我的代码中,我想将Excel文件与"DataTable"对象链接起来。我想访问Excel文件中的数据并将其存储在DataTable对象中。所以我使用了以下代码片段:

_

_connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source='"" + excelFile + "'";Extended Properties='Excel 8.0; HDR=NO; IMEX=1'";
        }
DataTable table = new DataTable();
            OleDbCommand command = new OleDbCommand();
            command.Connection = new OleDbConnection(_connectionString);
            command.CommandType = CommandType.Text;
            command.CommandText = "select * from [NameOFExcelSheet$A1:D20]";  // Want to read the Excel sheet. The name of Excel sheet is "NameOfExcelSheet". Wan to read the celles in the range A1 and D20.
            OleDbDataAdapter adapter = new OleDbDataAdapter();
            adapter.SelectCommand = command;
            adapter.Fill(table);  // EXCEPTION OCCURS IN THIS LINE. 

我安装了链接中可用的exehttp://www.microsoft.com/downloads/en/confirmation.aspx?FamilyID=7554F536-8C28-4598-9B72-EF94E038C891&displaylang=en

但在运行代码时,我仍然收到了相同的异常消息。我得到的例外是"'Microsoft.ACE.OLEDB.12.0'提供商未在本地计算机上注册"

PLz帮我解决这个问题。

提前谢谢。

如何摆脱异常";';Microsoft.ACE.OLEDB.12.0';提供者没有在本地机器上注册”

您可能使用64位Windows并安装了32位驱动程序。请切换到32位编译或源代码64位驱动程序。

您应该尝试一下(确保您在x86(32位)机器中):

此下载将安装一组组件,这些组件可用于促进2007 Microsoft Office System文件和非Microsoft Office应用程序之间的数据传输。

http://www.microsoft.com/downloads/en/details.aspx?FamilyID=7554F536-8C28-4598-9B72-EF94E038C891&displaylang=en