S
Scott M.
Why would this string of XML (when loaded into a DataSet) not produce a
DataTable with 2 columns? I am getting a DataTable with just one column
(ProductName). When I try to access the second column in the DataTable
(ds.Tables(0).Columns(1)), I get "Cannot find column 1". By the way, there
are no null values at all in the DataReader (dr).
'prodData is a StringBuilder
prodData.Append("<ProductData>")
If dr.HasRows Then
Do While dr.Read
prodData.Append("<ProductName>" & CType(dr.Item("Name"), String)
& "</ProductName>")
prodData.Append("<ProductID>" & CType(dr.Item("PartNumber"),
String) & "</ProductID>")
Loop
End If
prodData.Append("</ProductData>")
The XML string generated by this code is:
<?xml version="1.0" encoding="utf-8" ?>
<string xmlns="http://www.MyCompany.com/WorkflowLayer">
<ProductData>
<ProductName>Anod Nuke</ProductName>
<ProductID>AAN001</ProductID>
<ProductName>Avid 1D 20 Vbrakes</ProductName>
<ProductID>AVD001</ProductID>
...
...
...
<ProductName>World Class V-Adapters</ProductName>
<ProductID>WDC001</ProductID>
<ProductName>WTB Velociraptors</ProductName>
<ProductID>WTB001</ProductID>
</ProductData>
</string>
Any ideas?
DataTable with 2 columns? I am getting a DataTable with just one column
(ProductName). When I try to access the second column in the DataTable
(ds.Tables(0).Columns(1)), I get "Cannot find column 1". By the way, there
are no null values at all in the DataReader (dr).
'prodData is a StringBuilder
prodData.Append("<ProductData>")
If dr.HasRows Then
Do While dr.Read
prodData.Append("<ProductName>" & CType(dr.Item("Name"), String)
& "</ProductName>")
prodData.Append("<ProductID>" & CType(dr.Item("PartNumber"),
String) & "</ProductID>")
Loop
End If
prodData.Append("</ProductData>")
The XML string generated by this code is:
<?xml version="1.0" encoding="utf-8" ?>
<string xmlns="http://www.MyCompany.com/WorkflowLayer">
<ProductData>
<ProductName>Anod Nuke</ProductName>
<ProductID>AAN001</ProductID>
<ProductName>Avid 1D 20 Vbrakes</ProductName>
<ProductID>AVD001</ProductID>
...
...
...
<ProductName>World Class V-Adapters</ProductName>
<ProductID>WDC001</ProductID>
<ProductName>WTB Velociraptors</ProductName>
<ProductID>WTB001</ProductID>
</ProductData>
</string>
Any ideas?