DataTable oTbl = null; StatusLog = "Execution Started"; using (OleDbConnection oConn = new OleDbConnection(ExcelConnectionString)) { try { oConn.Open(); StatusLog += "\nConnection Opened"; using(OleDbCommand oComm = new OleDbCommand(SqlCommand, oConn)) { StatusLog += "\nExecution Started"; using(OleDbDataReader oRdr = oComm.ExecuteReader()) { oTbl = new DataTable(); oTbl.Load(oRdr); } } StatusLog += string.Format("\nData Loaded to Collection : Total Records {0}", oTbl.Rows.Count); } catch (Exception ex) { StatusLog += "\nException : "+ex.Message; } finally { if (oTbl != null) oTbl.Dispose(); oConn.Close(); StatusLog += "\nConnection Closed"; } } if (oTbl != null && oTbl.Rows.Count > 0) { StatusLog += "\nSQL Execution Started"; using (SqlConnection con = new SqlConnection(SqlConnectionString)) { try { con.Open(); StatusLog += "\nSQL Connection Opened"; using (SqlBulkCopy sqlBulkCopy = new SqlBulkCopy(con)) { //Set the database table name sqlBulkCopy.DestinationTableName = TableName; StatusLog += "\nSQL Insertion Started"; sqlBulkCopy.WriteToServer(oTbl); StatusLog += "\nSQL Insertion Completed"; } } catch (Exception ex) { StatusLog += "\nSQL Exception : "+ex.Message; } finally { con.Close(); StatusLog += "\nSQL Connection Closed"; } } }