private void databasexml_Click(object sender, EventArgs e) { string sql = "SELECT * FROM BookDetails"; DataSet ds = new DataSet(); BindingSource bs = new BindingSource(); SqlDataAdapter sda = new SqlDataAdapter(sql, stringConnection); try { ds.WriteXml("C:\\Users\\Louise Tooze\\Desktop\\XMLFile2.xml"); dataGridView1.DataMember = ""; sda.Fill(ds); dataGridView1.DataSource = ds.Tables[0]; dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dataGridView1.Update(); sda.Update(ds); sda.Dispose(); MessageBox.Show("XML File created Successfully"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
new DataSet ds
WriteXml
try { . . . // data filled in dataset sda.Fill(ds); // This line will be after you populate the dataset with data ds.WriteXml("C:\\Users\\Louise Tooze\\Desktop\\XMLFile2.xml"); . . . . . }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)