Write.XML from a DataSet

Hello XML Gurus,

I have what I hope is a relatively simple question; but since it's my first time with it, I'm hoping for a little guidance.

I have a DataSet (DataSet1) and I want to write one its tables ("Users") to an XML file (Users.xml). I think I understand how to write the whole dataset (and schema) to the xml file, but how do you do one table Also, when you call write.xml(filename), does it automatically overwrite the contents of the xml file or do I have to do something else in order for that to happen Lastly, when (and how) do you call the TableAdapter.Fill method to fill the new dataset with data

Any help would be greatly appreciated!

Thanks in advance for any help,

Tony




Answer this question

Write.XML from a DataSet

  • torvaldson

    http://msdn2.microsoft.com/en-us/system.data.datatable.writexml.aspx

    It will override the file if it already exists.

    Questions about DataSet should be asked in the .NET Framework Data Access and Storage forum.



  • Mike Riley

    Sergey,

    Thanks for the reply. I looked at the link you recommended prior to posting. The problem I had with it was it didn't provide an example. Since this is my first time trying to make this issue work, I was hoping for something a little more descriptive. As far as the DataSet goes, I thought this forum would be the best place to post since it's XML based. I'll try the other forum you mentioned.

    Thanks,

    Tony



  • yxrkt

    hope this can help u

    Dim ds As New DataSet

    Dim cn As New SqlConnection("Initial Catalog=PDA;Data Source=Maizatulakmal;Integrated Security=True;")

    Dim da As New SqlDataAdapter("select * from users", cn)

    da.Fill(ds, "users")

    ds.WriteXml("C:\try.xml")


  • Write.XML from a DataSet