protected void btnsave_Click(object sender, EventArgs e) { //Create connection string to Excel work book string excelConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=/BACKUP C DATA140312/Desktop/pratham/ActiveSub-Brokers" + Server.MapPath("Book1.xls") + ";" + "Extended Properties=Excel 8.0"; //Create Connection to Excel work book OleDbConnection excelConnection = new OleDbConnection(excelConnectionString); //Create OleDbCommand to fetch data from Excel OleDbCommand cmd = new OleDbCommand ("Select * from [Book1$]", excelConnection); excelConnection.Open(); OleDbDataReader dReader; dReader = cmd.ExecuteReader(); SqlBulkCopy sqlBulk = new SqlBulkCopy(strConnection); sqlBulk.DestinationTableName = "tblActiveSubBroker"; //sqlBulk.ColumnMappings.Add("ID", "ID"); //sqlBulk.ColumnMappings.Add("Name", "Name"); sqlBulk.WriteToServer(dReader); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)