Answered by:
Problem with loading xml file into Dataset

Question
-
Hi All
Can anyone help please?
I am trying to load an xml file my project as a new Dataset.
I have used the following code, but the Dataset does not appear in my project. Is there something else I need to do?
Thank you in advance.
Dim dSet As New DataSet
Dim fs As FileStream
fn = "C:\Users\Wednesday\Documents\Visual Studio 2010\Projects\TestingWordCombinations\DSTest.xml"fs = New FileStream(fn, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)
dSet.ReadXml(fs)
fs.close
End Sub
Thursday, June 9, 2011 8:53 AM
Answers
-
Wednesday
There are some old samples going around and it seems your code is based on that,
Normally this is enough
Dim dSet as New Dataset
dSet.ReadXML( "C:\Users\Wednesday\Documents\Visual Studio 2010\Projects\TestingWordCombinations\DSTest.xml")
Success
Cor- Proposed as answer by Mike FengModerator Friday, June 10, 2011 11:24 AM
- Marked as answer by Mike FengModerator Tuesday, June 21, 2011 10:56 AM
Friday, June 10, 2011 6:13 AM
All replies
-
Hello Wednesday61,
try to see this thread
Hello
Carmelo La Monica http://community.visual-basic.it/carmelolamonica/Thursday, June 9, 2011 9:02 AM -
Hi Carmelo
Thank you for your reply. I have looked at the links and tried to incorporate the extra steps into my code - still not working. My DSTest.xml has 5 columns to my code, as per the link instructions. The new dataset still does not appear anywhere in my project. Any other suggestions would be much appreciated.
Regards
Wednesday
Thursday, June 9, 2011 9:46 AM -
You can read the XML to dataset directly from file
dataSet.ReadXml("file.xml");
Are you getting any error ?
Malayalam SMS Website http://aspspider.info/smsmalluThursday, June 9, 2011 1:03 PM -
Hi Nishanth
Thank you for your reply.
I am not getting any error, but only the Dataset.xml appears in my project.
Should there not be a Dataset.xsd file?
Could it be that my xml file is not in the correct format?
I am very frustrated with this.
I am attaching a small extract of the xml file (DSTest.xml) I have in case you can see anything obvious.
I am trying to get a net Version of this into my project. Any help would be greatly appreciated.
<?
xml version="1.0" standalone="yes"
?>
<
NewDataSet
>
<
DTTest
>
<
Column1>Product Id</Column1
>
<
Column2>Combinations</Column2
>
<
Column3>First Selection</Column3
>
<
Column4>Second Selection</Column4
>
<
Column5>Third selection</Column5
>
</
DTTest
>
<
DTTest
>
<
Column1>1</Column1
>
<
Column2>Brie, Cheddar, Goat's Cheese</Column2
>
</
DTTest
>
<
DTTest
>
<
Column1>2</Column1
>
<
Column3>Brie</Column3
>
</
DTTest
>
Regards
Wednesday
Thursday, June 9, 2011 3:20 PM -
Your your code and XML, I am able to load the XML data into the dataset. Only issue I find with XML is, it does not have the closing tag at the end </NewDataSet>
Malayalam SMS Website http://aspspider.info/smsmalluFriday, June 10, 2011 5:07 AM -
Wednesday
There are some old samples going around and it seems your code is based on that,
Normally this is enough
Dim dSet as New Dataset
dSet.ReadXML( "C:\Users\Wednesday\Documents\Visual Studio 2010\Projects\TestingWordCombinations\DSTest.xml")
Success
Cor- Proposed as answer by Mike FengModerator Friday, June 10, 2011 11:24 AM
- Marked as answer by Mike FengModerator Tuesday, June 21, 2011 10:56 AM
Friday, June 10, 2011 6:13 AM -
Hi Cor
Thank you for your reply.
It is now working.
Regards
Wednesday
Friday, June 10, 2011 4:11 PM