This generic error message is often an indication of a syntax error in the connection string. In my case the error occurred when I tried to add a second Extended Property, like so:
var connection = new System.Data.OleDb.OleDbConnection(
"Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + path + ";" +
"Extended Properties=Excel 8.0;HDR=No;");
The problem turned out to be that the multiple extended properties were not quoted. A single extended property does not need quoting, but multiple do.
The fix was then simply to add escaped quotes:
var connection = new System.Data.OleDb.OleDbConnection(
"Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + path + ";" +
"Extended Properties=\\"Excel 8.0;HDR=No;\\"");
Comments