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; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)