尝试读取 Excel XLSB 时 OleDbConnection.Open() 出错
Error in OleDbConnection.Open() when trying to read Excel XLSB
我正在使用 Visual Studio 2013 和 MVC 3 Razor。我能够上传和保存 XLSB 文件,并且我正在尝试从上传的 XLSB 中读取数据。我有以下连接字符串和方法来初始化 OleDbConnection:
strConStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Projects\Excel1.xlsb;Extended Properties='Excel 8.0;HDR=True'";
OleDbConnection connExcel = new OleDbConnection(strConStr);
错误发生在connExcel.Open()。以下是错误消息:
An exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll but was not handled in user code
Additional information: This file was created in a previous beta version of Excel 2007. Open the file with Excel 2007 to save it to the most recent version of the Excel 2007 file format before opening the file in Access 2007.
我的 PC 上安装了 AccessDatabaseEngine。在我的控制面板中,我安装了以下引擎信息:
Name: Microsoft Office Access database engine 2007 (English)
,Size: 19.2 MB
,Version: 12.0.4518.1031
我不确定这是否是读取 XLSB 文件的正确版本。顺便说一下,我的电脑是 x64 位的。
我的同事也在他的电脑上安装了相同类型的 Microsoft Office Access 数据库引擎 2007,但他的版本是“12.0.66XX”,代码在他这边工作正常。
如果我需要安装另一个版本的 Access 数据库引擎,或任何其他解决此错误的方法,请告诉我。
经过长时间的学习和研究,我能够解决这个问题。
除了我机器上已经安装的 Microsoft Office Access 数据库引擎 2007,我还下载并安装了 Microsoft Access Database Engine 2010 Redistributable。
之后,我需要下载Microsoft Office Access Runtime and Data Connectivity 2007 Service Pack 2 (SP2)进行安装,然后重启我的机器。
之后一切都像魔术一样工作。
这是我的工作连接字符串:
strConStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Projects\Excel1.xlsb;Extended Properties='Excel 12.0;HDR=True'";
我正在使用 Visual Studio 2013 和 MVC 3 Razor。我能够上传和保存 XLSB 文件,并且我正在尝试从上传的 XLSB 中读取数据。我有以下连接字符串和方法来初始化 OleDbConnection:
strConStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Projects\Excel1.xlsb;Extended Properties='Excel 8.0;HDR=True'";
OleDbConnection connExcel = new OleDbConnection(strConStr);
错误发生在connExcel.Open()。以下是错误消息:
An exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll but was not handled in user code
Additional information: This file was created in a previous beta version of Excel 2007. Open the file with Excel 2007 to save it to the most recent version of the Excel 2007 file format before opening the file in Access 2007.
我的 PC 上安装了 AccessDatabaseEngine。在我的控制面板中,我安装了以下引擎信息:
Name: Microsoft Office Access database engine 2007 (English) ,Size: 19.2 MB ,Version: 12.0.4518.1031
我不确定这是否是读取 XLSB 文件的正确版本。顺便说一下,我的电脑是 x64 位的。
我的同事也在他的电脑上安装了相同类型的 Microsoft Office Access 数据库引擎 2007,但他的版本是“12.0.66XX”,代码在他这边工作正常。
如果我需要安装另一个版本的 Access 数据库引擎,或任何其他解决此错误的方法,请告诉我。
经过长时间的学习和研究,我能够解决这个问题。
除了我机器上已经安装的 Microsoft Office Access 数据库引擎 2007,我还下载并安装了 Microsoft Access Database Engine 2010 Redistributable。
之后,我需要下载Microsoft Office Access Runtime and Data Connectivity 2007 Service Pack 2 (SP2)进行安装,然后重启我的机器。
之后一切都像魔术一样工作。
这是我的工作连接字符串:
strConStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Projects\Excel1.xlsb;Extended Properties='Excel 12.0;HDR=True'";