You can use below code
using (OleDbConnection con = new OleDbConnection(excelCS))
{
OleDbCommand cmd = new OleDbCommand("select * from [Sheet1$]", con);
con.Open();
// Create DbDataReader to Data Worksheet
DbDataReader dr = cmd.ExecuteReader();
// SQL Server Connection String
//string CS = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
string CS = objCommon.TestConnection;
// Bulk Copy to SQL Server
SqlBulkCopy bulkInsert = new SqlBulkCopy(CS);
bulkInsert.ColumnMappings.Add("Kcode", "Kcode");
bulkInsert.ColumnMappings.Add("MDMCode", "MDMCode");
bulkInsert.DestinationTableName = "tbl_MDMKcodeMapping";
bulkInsert.WriteToServer(dr);
lblMessage.Text = "Your file uploaded successfully";
lblMessage.ForeColor = System.Drawing.Color.Green;
}
Please note that in
bulkInsert.ColumnMappings.Add("Kcode", "Kcode");
The first parameter should be your Excel column name and the second parameter should be your SQL table column name