Solved

Read data from xml file

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

808 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