|
-
Oct 11th, 2002, 07:12 AM
#1
Thread Starter
Fanatic Member
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 ???????
-
Oct 11th, 2002, 07:48 AM
#2
Fanatic Member
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
-
Oct 11th, 2002, 07:53 AM
#3
Thread Starter
Fanatic Member
Thanks for your feedback.
I cracked it. Silly mistake on my part.
-
Oct 11th, 2002, 07:57 AM
#4
Fanatic Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|