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

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();

Upvotes: 2

Views: 1935

Answers (2)

AleRubis
AleRubis

Reputation: 264

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/

Upvotes: 3

Chou George
Chou George

Reputation: 61

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

Upvotes: 2

Related Questions