Click here to Skip to main content
15,892,643 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Any of the following exceptions occurs (IIS 8) once or twice in a week.

* Error Message:System.InvalidOperationException: The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.

* Error Message:System.Data.OleDb.OleDbException (0x80004005): Could not find installable ISAM.

* Error Message:System.Data.OleDb.OleDbException (0x80004005): External table is not in the expected format.

Excel 2007 file is used. The code follows below.
string xlsxOleDBConnection = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties='Excel 12.0;HDR=YES;IMEX=1'";

DataTable dt = new DataTable();

using (OleDbConnection l_oleConnection = new OleDbConnection(string.Format(xlsxOleDBConnection, FileNameWithPath)))

{
string l_strSQL = string.Format("SELECT {0} FROM [{1}]", strColumns,    WebConfigurationManager.AppSettings["ExcelSheetName"].ToString());
l_oleConnection.Open();
OleDbCommand l_oleCommand = new OleDbCommand(l_strSQL, l_oleConnection);
OleDbDataAdapter da = new OleDbDataAdapter(l_oleCommand);
da.Fill(dt);
l_oleConnection.Close();
OleDbConnection.ReleaseObjectPool();
return dt;
}

After restarting the app pool, everything works fine for two to three days and again above exception occurs.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900