Loading Data Into DataSet From XML

G

Guest

I'm having a difficult time making the jump from VB6 and ASP to the .NET Compact Framework and am pretty much stalled on the app I'm trying to develop for an Intermec Mobile Computer.

I need a disconnected DataSet in the device and it appears the best way to get it there is to transfer an XML file from the server and then load the XML into a DataSet. Trouble is, no matter how I try to get it in, I get either a "FileNotFound Exception" or an "IO Exception". I've put the XML file in every location it could possibly go (or at least I think I have) and still get the error.

I've tried some of the sample apps in the VB .NET Resource Kit and can get SQL Data in/out and get/save it from XML, but when I try to go to the Compact Framework and my Smart Device platform, it doesn't work with what's available there.

Can anyone offer help in the form of sample code or by pointing me to a good resource? I'll even take a class, IF I can find one that's affordable.

Thanks in advance.
 
G

Guest

Sorry about the duplication. The MS server said there was a problem posting the message, so I re-did it.
 
M

Mark Ihimoyan [MSFT]

I suggest that you put the XML file in the same folder that you put your
executable. You can then get the fully qualified path and attempt to load
your XML from there.
Here is an example of how to do this in VB.NET. Assume the name of your xml
file is foo.xml

Dim ds As DataSet = New DataSet

Dim _path As String =
Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetN
ame().CodeBase)

ds.ReadXml(_path & "\foo.xml")

Console.WriteLine("Done loading")

HTH

Art Cabot said:
I'm having a difficult time making the jump from VB6 and ASP to the .NET
Compact Framework and am pretty much stalled on the app I'm trying to
develop for an Intermec Mobile Computer.
I need a disconnected DataSet in the device and it appears the best way to
get it there is to transfer an XML file from the server and then load the
XML into a DataSet. Trouble is, no matter how I try to get it in, I get
either a "FileNotFound Exception" or an "IO Exception". I've put the XML
file in every location it could possibly go (or at least I think I have) and
still get the error.
I've tried some of the sample apps in the VB .NET Resource Kit and can get
SQL Data in/out and get/save it from XML, but when I try to go to the
Compact Framework and my Smart Device platform, it doesn't work with what's
available there.
Can anyone offer help in the form of sample code or by pointing me to a
good resource? I'll even take a class, IF I can find one that's affordable.
 
G

Guest

THANK YOU!!! This was the fix; it showed that the app was looking for it in \ProgramFiles\AppFolder, which was the top level folder and didn't have "ProgramFiles" anywhere near it. When I gave it that path and put the XML file there, it loaded fine.

Now I can't get it to write the file back using ds.writeXML(filename). It doesn't throw an exception, it just doesn't write anything.

Mark or anyone who might be following this thread have any ideas?
--
Art Cabot
Strickland Technical Services, Inc.
Augusta, Georgia


Mark Ihimoyan said:
I suggest that you put the XML file in the same folder that you put your
executable. You can then get the fully qualified path and attempt to load
your XML from there.
Here is an example of how to do this in VB.NET. Assume the name of your xml
file is foo.xml

Dim ds As DataSet = New DataSet

Dim _path As String =
Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetN
ame().CodeBase)

ds.ReadXml(_path & "\foo.xml")

Console.WriteLine("Done loading")

HTH

Art Cabot said:
I'm having a difficult time making the jump from VB6 and ASP to the .NET
Compact Framework and am pretty much stalled on the app I'm trying to
develop for an Intermec Mobile Computer.
I need a disconnected DataSet in the device and it appears the best way to
get it there is to transfer an XML file from the server and then load the
XML into a DataSet. Trouble is, no matter how I try to get it in, I get
either a "FileNotFound Exception" or an "IO Exception". I've put the XML
file in every location it could possibly go (or at least I think I have) and
still get the error.
I've tried some of the sample apps in the VB .NET Resource Kit and can get
SQL Data in/out and get/save it from XML, but when I try to go to the
Compact Framework and my Smart Device platform, it doesn't work with what's
available there.
Can anyone offer help in the form of sample code or by pointing me to a
good resource? I'll even take a class, IF I can find one that's affordable.
 
M

Mark Ihimoyan [MSFT]

It works for me.
Is the file created at least?
How are you trying to view the file?
Thanks.

Art Cabot said:
THANK YOU!!! This was the fix; it showed that the app was looking for it
in \ProgramFiles\AppFolder, which was the top level folder and didn't have
"ProgramFiles" anywhere near it. When I gave it that path and put the XML
file there, it loaded fine.
Now I can't get it to write the file back using ds.writeXML(filename). It
doesn't throw an exception, it just doesn't write anything.
Mark or anyone who might be following this thread have any ideas?
--
Art Cabot
Strickland Technical Services, Inc.
Augusta, Georgia
 
G

Guest

I've tried every way that the books say, with an XMLTextWriter, a straight writeXML, it's all the same. It breezes right on through like it's really happening (and I'm using the Path + Filename that made the readXML work) and throws no exception. When I open the directory that I read the original from (the Path + Filename location), it's not there.

It's a directory I have all rights to, but if it was a security problem, I'd think it'd throw an exception. I've checked the DataSet and there's data there.

What could possibly be causing this? I'm going to post this question in a new thread, just in case nobody else is reading down this deep.
--
Art Cabot
Strickland Technical Services, Inc.
Augusta, Georgia
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top