private void button2_Click(object sender, EventArgs e) { string path = "E:\\BatchMaster.xls"; string excelConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;Persist Security Info=False"; OleDbConnection excelConnection = new OleDbConnection(excelConnectionString); OleDbCommand cmd = new OleDbCommand("Select *from [Sheet1$]", excelConnection); excelConnection.Open(); OleDbDataReader dReader; dReader = cmd.ExecuteReader(); SqlBulkCopy sqlBulk = new SqlBulkCopy(con); sqlBulk.DestinationTableName = "BatchMaster"; sqlBulk.WriteToServer(dReader); excelConnection.Close(); MessageBox.Show("Successful"); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)