string excelConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\medi.xlsx;Extended Properties=""Excel 12.0 Xml;HDR=YES""";
// string excelConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\\medi.xlsx;Extended Properties=Excel 12.0;";
string sqlConnectionString =ConfigurationManager.ConnectionStrings["sqlcon"].ConnectionString;
//Create Connection to Excel work book
OleDbConnection excelConnection = new OleDbConnection(excelConnectionString);
//Create OleDbCommand to fetch data from Excel
OleDbCommand cmd = new OleDbCommand
("Select * from [medi1$]",excelConnection);
excelConnection.Open();
OleDbDataReader dReader;
dReader = cmd.ExecuteReader();
// Create object for SqlBulkCopy
SqlBulkCopy sqlBulk = new SqlBulkCopy(sqlConnectionString);
sqlBulk.DestinationTableName = "demo";
sqlBulk.WriteToServer(dReader);