views:

224

answers:

2

Hello,

I found several examples on how to write to dataset, but most of them involve a ds.fill(..) from a data connection and I need a simpler solution. Basically I want to create an xml file from the values entered in a few textbox. I tried different methods but can't make it work. What is the best way to accomplish this?

One method I used was to fill the textboxes from an xml, but now how do I write it back to the xml once the user has changed the data in the textbox?

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim ds As New DataSet
    ds.ReadXml("c:\sales.xml")
    CashTextBox.DataBindings.Add("Text", ds.Tables(0), "Cash")
    CheckTextBox.DataBindings.Add("Text", ds.Tables(0), "Check")
    VisaTextBox.DataBindings.Add("Text", ds.Tables(0), "Visa")
    MasterCardTextBox.DataBindings.Add("Text", ds.Tables(0), "Mastercard")
    AMEXTextBox.DataBindings.Add("Text", ds.Tables(0), "AMEX")
    NovusTextBox.DataBindings.Add("Text", ds.Tables(0), "Novus")
    TottransTextBox.DataBindings.Add("Text", ds.Tables(0), "Tottrans") End Sub

Thank you!

A: 

Not sure what the intent here is, but one way you could do this is:

Create a DataSet
Add a DataTable
Add DataRows with your relevant information from each text box as a DataRow for each relevant text box.
Call WriteXml on the DataSet

EDIT: Here is an example thrown together based on your comment, it's simplistic, I've iterated through a loop instead of all textboxes: http://www.pastie.org/806266. You might want to update your question in terms of what your overall goal is, looping through text boxes to stuff things in a data set and then call write WriteXml is pretty old school, 3.5 makes constructing XML much easier, can you elaborate on what your long term goal is.

RandomNoob
by any chance you have an example? Thanks!
chupeman
A: 

Am I missing something? Can't you just use ds.WriteXml

HadleyHope
Looks like I didn't ask correctly... = )In the code above I am using the Load event of the form to fill the text boxes. When I am trying to add the ds.writeXML to the buttonclick event it's telling me that ds is not defined.I just need an example of how to write the user inputs from the textbox.text once modified.
chupeman