Solved

Read data from xml file

Posted on 2004-08-31
2
200 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 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

706 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now