protected void Button1_Click(object sender, EventArgs e){try{string cs = ConfigurationManager.ConnectionStrings["SchoolConnectionString"].ConnectionString;using (SqlConnection sqlConn = new SqlConnection(cs)){DataSet ds = new DataSet();ds.ReadXml(Server.MapPath("~/Data.xml"));DataTable dtStudentMaster = ds.Tables["Student"];sqlConn.Open();using (SqlBulkCopy sqlbc = new SqlBulkCopy(sqlConn)){sqlbc.DestinationTableName = "StudentMaster";sqlbc.ColumnMappings.Add("Name", "Name");sqlbc.ColumnMappings.Add("Phone", "Phone");sqlbc.ColumnMappings.Add("Address", "Address");sqlbc.ColumnMappings.Add("Class", "Class");sqlbc.WriteToServer(dtStudentMaster);Response.Write("Bulk data stored successfully");}}}catch (Exception ex){throw ex;}}
Loading
