Solved

Read data from xml file

Posted on 2004-08-31
2
236 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 250 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

628 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