Export DataGrid data to an XML File

June 30, 2008 at 10:45 AM

Export DataGrid data to an XML File.

[silverlight:/exportXML.wmv] 

To export data from datagrid to XML, you can use WriteXML function.

Example :

        Dim myCommand As SqlDataAdapter
        myCommand = New SqlDataAdapter("Select * from student", myconn)
        ' declare the dataset function
        Dim ds As DataSet = New DataSet()
        myCommand.Fill(ds, "student")
        DataGridView1.DataSource = (ds)
        DataGridView1.DataSource = ds.Tables(0)


        ds.WriteXml("c:\student.xml")

Download : exportXML.wmv (680.55 kb)

Posted in: Technical Stuff

Tags: