Results 1 to 4 of 4

Thread: XML problem - Sorry to bother to you again

  1. #1

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    XML problem - Sorry to bother to you again

    I create a datatable, style e.t.c. at the top of my form with the following code.

    Dim dtPickle As New DataTable("Pickle")
    Dim dgTSPickle As New DataGridTableStyle()
    Dim dgC1 As New DataGridTextBoxColumn()
    Dim dgC2 As New DataGridTextBoxColumn()
    Dim dgC3 As New DataGridTextBoxColumn()
    Dim dgC4 As New DataGridTextBoxColumn()

    I then create my columns, add theses to the datatable and make this table the source of a datagrid (Simplified a little here to keep it short)

    'Add columns to datatable
    dtPickle.Columns.Add(New DataColumn("Code", GetType(String)))
    Me.DataGrid2.DataSource = dtPickle
    'Create column styles and add to TableStyle
    Me.dgC1.MappingName = "Code"
    Me.dgC1.Width = 60
    Me.dgC1.HeaderText = "Code"
    'Add column styles to TableStyle
    Me.dgTSPickle.GridColumnStyles.Add(dgC1)
    'Add TableStyle to Datagrid
    Me.DataGrid2.TableStyles.Add(dgTSPickle)
    Me.DataGrid2.Refresh()

    I then add rows to the datatable with the following:

    Dim rowP As DataRow
    rowP = dtPickle.NewRow()
    rowP(0) = Me.txtCode.Text

    dtPickle.Rows.Add(rowP)

    And then I create a dataset, add the table to the dataset and write the contents to an XML file:

    Dim ds As DataSet = New DataSet()
    ds.Tables.Add(Me.dtPickle)
    ds.WriteXml("C:\mydata.xml")

    The XML file is Blank.
    WHY ???????

    Parksie

  2. #2
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    518
    You're doing some things I'm not familiar with (haven't worked with DataGridTextBoxColumn for example) but I added a multiline textbox and the line:

    TextBox1.Text = ds.GetXML

    And got some XML. Probably your problem is with some idiosyncracy of WriteXML, try playing with GetXML first - WriteXML is a little bit more complex than how you're trying to use it, take a look at this example:

    ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfSystemDataDataSetClassWriteXmlTopic.htm

  3. #3

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018
    Thanks for your feedback.

    I cracked it. Silly mistake on my part.

    Parksie

  4. #4
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    518
    Cheers!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width