OleDb exception when trying to make connection with Excel

时间:2017-10-12 09:38:54

标签: c# excel oledbconnection

I am developing a C# Windows Form Application which read and write data to Excel file such as 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. I am working on this application from last 4 to 5 days. 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();

2 个答案:

答案 0 :(得分:3)

It seems to be an error introduced by the last 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.

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/

答案 1 :(得分:2)

Remove the following KB to solve this problem
Windows 10 Version 1703 - KB4041676
Windows 10 Version 1607 and Windows Server 2016 - KB4041691
Windows 8.1 and Windows Server 2012 - KB4041693
Windows 7 and Windows Server 2008 R2 - KB4041681
Due to the windows update on the second week of October 2017