conStr = String.Format(conStr, FilePath, isHDR);
OleDbConnection connExcel = new OleDbConnection(conStr);
OleDbCommand cmdExcel = new OleDbCommand();
OleDbDataAdapter oda = new OleDbDataAdapter();
DataTable dt = new DataTable();
cmdExcel.Connection = connExcel;
//Get the name of First Sheet
connExcel.Open();
DataTable dtExcelSchema;
dtExcelSchema = connExcel.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
string SheetName = dtExcelSchema.Rows[0]["TABLE_NAME"].ToString();
connExcel.Close();
I am using above code to read excel. But it stuck at connExcel.Close(); for few seconds and then move to next statement. This is causing late processing on the page. Any suggestions??
Updating my question to give more details.
test case:- I uploaded an xls file it took normal time. I uploaded an xlsx file it halt at connExcel.close() for 25sec. Now i uploaded an xls file and it halt for xls also.
i have used following connection strings
for xls :- connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0}; Extended Properties='Excel 8.0;HDR={1}'"
for xlsx :- connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0}; Extended Properties='Excel 8.0;HDR={1}'"
来源:https://stackoverflow.com/questions/31180822/oledbconnection-close-method-taking-long-execution-time