XML data into XMLDataDoc ...help

  • Thread starter Thread starter Dave
  • Start date Start date
D

Dave

Hi
I have decided to use the method explained in the first
example here
http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/cpguide/html/cpconsynchronizingdatasetwithxmldatadocume
nt.asp
To try and load data from an xml file into an XMLDataDoc
and then into a SQL Table

however, i'm a newbie to this and the bit i want to know
is how to:
' Add code to populate the DataSet with schema and data.

is there any example code or tutorials out there that can
help me please?

THanks
 
Hi Dave,

It just means that you should be filling the dataset with something.

Here's some code I modified from the samples to generate a datatable for use
in a dataset:


Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim myDataSet As DataSet = New DataSet
' Add code here to populate the DataSet with schema and data.
myDataSet.Tables.Add(CreateDataSource())
Dim xmlDoc As XmlDataDocument = New XmlDataDocument(myDataSet)
Response.Write(xmlDoc.OuterXml)
End Sub

Function CreateDataSource() As DataTable
Dim dt As New DataTable
Dim dr As DataRow
dt.Columns.Add(New DataColumn("IntegerValue", GetType(Int32)))
dt.Columns.Add(New DataColumn("StringValue", GetType(String)))
dt.Columns.Add(New DataColumn("CurrencyValue", GetType(Double)))
dt.Columns.Add(New DataColumn("Boolean", GetType(Boolean)))
Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = i
dr(1) = "Item " + i.ToString()
dr(2) = 1.23 * (i + 1)
dr(3) = True
dt.Rows.Add(dr)
Next i
Return dt
End Function 'CreateDataSource
 
Back
Top