Error:
System.InvalidOperationException: 'The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine.'
I encountered an error while trying to read an Excel file in my ASP.NET web application.
Here is the SQL connection string I am using:
if (Path.GetExtension(filePath) == ".xls"){ connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source {0};Extended Properties='Excel 8.0;HDR=YES;IMEX=1'";}else if (Path.GetExtension(filePath) == ".xlsx"){ connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source {0};Extended Properties='Excel 8.0;HDR=YES;IMEX=1'";}connectionString = string.Format(connectionString, filePath);
When I try to open the connection, I receive the error mentioned above.
Things I have already installed:
- Microsoft ODBC Driver 17 for SQL Server (version 17.10.6.1)
- Microsoft OLE DB Driver for SQL Server (version 18.7.4.0)
I have tried both .xls
and .xlsx
file extensions, but the issue persists.
I would appreciate any guidance or suggestions on how to resolve this issue. 😊