Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Data from XML not being read to dataset
Message
From
12/08/2010 17:53:48
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
 
 
To
12/08/2010 15:44:01
General information
Forum:
ASP.NET
Category:
XML
Environment versions
Environment:
VB 9.0
Miscellaneous
Thread ID:
01476381
Message ID:
01476401
Views:
43
>When I read a XmlDocument into a DataSet, the structure defined in the schema is created but the datarows are not being populated.
>
>
>            Dim XMLreader As StringReader = New System.IO.StringReader(XMLstring)
>            Dim DS As DataSet = New DataSet
>            DS.ReadXml(XMLreader, XmlReadMode.ReadSchema)
>
>            Dim dr As DataRow = DS.Tables(0).Rows(0)     ' <= error: "there is no row at position 0"
>
>
>The rows collection has a count of 0. I know there around a hundred rows in the Xml string.
>
>I googled around, but nearly all the examples are the same or similar to one I have here.
>
>I would not mind if the xml string is flawed. but no error or exception is generated. The dataset's HasErrors reports false.
>
>Any help would be great.

You shouldn't need to call AcceptChanges but if the visualizer indicates no data in the dataset then it must be something wrong with the XML file. Did you try this without the XmlReadMode parameter? not sure what your XML file is like. you could also try using a different known xml source.
Tim

Update: After reading my comment I wasn't very clear about the XmlReadMode. If the Xml schema is causing a problem try just changing the parameter to InferSchema to test.
Tim
Timothy Bryan
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform