Hi
Perhaps someone can help.
I've got an XSD, produced in Visual Studio, called ProductionDataSet.xsd with one DataTable named "ProductionData"
"ProductionData" has numeric fields; say they are called FieldA, FieldB, FieldC
Nothing fancy for this trial or any restrictions.
I used the xsd.exe to create strongly typed .VB class, called "ProductionDataSet.vb"
So now the dataset and schema is setup correctly I think.
In the code I create a dummy set of data and try exporting it to an XML file using the WriteXML.
If I have
Dim ds2 As New DataSet
ds2.ReadXmlSchema(filename
) 'filename is ProductionDataSet.xsd
'add data here..
ds2.Tables(0).Rows.Add("1"
, "2", "3")
ds2.Tables(0).Rows.Add("4"
, "6", "10")
ds2.Tables(0).Rows.Add("5"
, "8", "12")
'output to XML file
myXmlDataDocument.DataSet.
WriteXml("
c:\output1
.xml")
the output works fine for above:
<?xml version="1.0" standalone="yes"?>
<ProductionDataSet xmlns="
http://tempuri.org/ProductionDataSet.xsd">
<ProductionData>
<FieldA>1</FieldA>
<FieldB>2</FieldB>
<FieldC>3</FieldC>
</ProductionData>
<ProductionData>
<FieldA>4</FieldA>
<FieldB>6</FieldB>
<FieldC>10</FieldC>
</ProductionData>
<ProductionData>
<FieldA>5</FieldA>
<FieldB>8</FieldB>
<FieldC>12</FieldC>
</ProductionData>
</ProductionDataSet>
HOWEVER this uses an array of parameters, not strongly typed......so I thought I could use
Dim production As New ProductionDataSetProductio
nData()
production.FieldA = 123
production.FieldB = 456
ds2.Tables(0).Rows.Add(pro
duction)
The output it produces appends to the above and is a problem. Instead of appending
<ProductionData>
<FieldA>123</FieldA>
<FieldB>456</FieldB>
</ProductionData>
I get......
<ProductionData>
<FieldA>ProductionDataSetP
roductionD
ata</Field
A>
</ProductionData>
What is going up here? Obviously <FieldA>ProductionDataSetP
roductionD
ata</Field
A> isn't what I want.
Thanks in advance for help - this is really troubling me
Start Free Trial