Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Data from XML not being read to dataset
Message
De
12/08/2010 17:53:48
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
 
À
12/08/2010 15:44:01
Information générale
Forum:
ASP.NET
Catégorie:
XML
Versions des environnements
Environment:
VB 9.0
Divers
Thread ID:
01476381
Message ID:
01476401
Vues:
44
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform