Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Read data from xml file

Posted on 2004-08-31
2
Medium Priority
?
241 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 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

730 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