Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Read data from xml file

Posted on 2004-08-31
2
Medium Priority
?
244 Views
Last Modified: 2010-04-15
Hi,

I have problem with reading data from xml file into DataSet.
Problem is that after I import xml file into DataSet all coulumns in Table are
of type string no matter that in scheme file is one of columns type decimal:

<xs:element name="Price" msdata:ReadOnly="true" msdata:type="xs:decimal" minOccurs="0" />

I dont have lots of experience with xml in NET so I need some ideas?

Thanks
Tomaz
0
Comment
Question by:tomazsr
2 Comments
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 750 total points
ID: 11947041
http://go.microsoft.com/fwlink/?linkid=3480&path=/quickstart/howto/samples/Xml/LoadDataSetXMLData/LoadDataSetXMLData.src

is a full example ... note you have to read the XML schema first other wise everything will be strings.
0
 
LVL 1

Author Comment

by:tomazsr
ID: 11947278
I try with MS code but its the same. So here is my code:

private DataSet ReadData(string DataFileName,string SchemaFileName,string DataSetName)
            {
                  FileStream FileStreamSchema = new FileStream(SchemaFileName,FileMode.Open,FileAccess.Read,FileShare.Read);
                  FileStream FileStreamData = new FileStream(DataFileName,FileMode.Open,FileAccess.Read,FileShare.Read);
                  DataSet DataSetOut=new DataSet(DataSetName);

                  try
                  {
                        DataSetOut.ReadXmlSchema(FileStreamSchema);
                        DataSetOut.ReadXml(FileStreamData);
                  }
                  catch( Exception ex)
                  {
                        MessageBox.Show(ex.Message);
                  }
                  finally
                  {
                        FileStreamSchema.Close();
                        FileStreamData.Close();
                  }
                  return DataSetOut;
            }

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question