简体   繁体   English

尝试与Excel建立连接时出现OleDb异常

[英]OleDb exception when trying to make connection with Excel

I am developing a C# Windows Form Application which read and write data to Excel file such as data.xls 我正在开发一个C#Windows窗体应用程序,该程序可以将数据读写到Excel文件(例如data.xls)中。

I have made my connection string as: 我将连接字符串设置为:

string Excel03ConString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties='Excel 8.0;HDR=YES'";

My data.xls file is in Project's bin folder. 我的data.xls文件位于Project的bin文件夹中。 I am working on this application from last 4 to 5 days. 我在过去4到5天内正在处理此应用程序。 Till now, my application was working fine. 到现在为止,我的应用程序运行良好。 But from today, it starts giving an error 但是从今天开始,它开始出现错误

Unexpected error from external database driver (1).

on con.open(); 在con.open();上

It seems to be an error introduced by the last Windows Update. 上次Windows Update似乎引入了错误。

To avoid this error you can change the provider in connection string to Microsoft.ACE.OLEDB.12.0 instead of Microsoft.Jet.OLEDB.4.0 . 为避免此错误,您可以将连接字符串中的提供程序更改为Microsoft.ACE.OLEDB.12.0而不是Microsoft.Jet.OLEDB.4.0

https://blogs.msdn.microsoft.com/dataaccesstechnologies/2017/10/18/unexpected-error-from-external-database-driver-1-microsoft-jet-database-engine-after-applying-october-security-updates/ https://blogs.msdn.microsoft.com/dataaccesstechnologies/2017/10/18/unexpected-error-from-external-database-driver-1-microsoft-jet-database-engine-after-applying-october-security-更新/

Remove the following KB to solve this problem 删除以下知识库以解决此问题
Windows 10 Version 1703 - KB4041676 Windows 10版本1703-KB4041676
Windows 10 Version 1607 and Windows Server 2016 - KB4041691 Windows 10版本1607和Windows Server 2016-KB4041691
Windows 8.1 and Windows Server 2012 - KB4041693 Windows 8.1和Windows Server 2012-KB4041693
Windows 7 and Windows Server 2008 R2 - KB4041681 Windows 7和Windows Server 2008 R2-KB4041681
Due to the windows update on the second week of October 2017 由于Windows在2017年10月的第二周更新

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM