CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2009
    Posts
    1

    XML as a DataSource

    Hello,
    I am make an application with C#, VS 2005, that reads and writes info to an XML file.
    I would like to add a report to display the information of the xml file.
    How ever i can't seem to add the xml file as a data source for the report.
    can someone please help me?
    thank you

  2. #2
    Join Date
    Jul 2007
    Location
    Illinois
    Posts
    517

    Re: XML as a DataSource

    You could read the xml file into a DataSet object and use that. The DataSet (and DataTable) contains a function for reading in XML data from a file and storing it in a DataSet. You should create the DataSet first in code:

    Code:
    DataSet dataset = new DataSet("myDataSet");
    
    // Read the xml data into the DataSet object
    // The myDataFile.xml file must contain data formatted in
    // such a way that it can be loaded into the DataSet
    dataSet.ReadXml("myDataFile.xml");
    
    // You can save the data to XML
    // You may want to do this first so you have a file
    // formatted for being read into the DataSet.
    dataSet.WriteXml("myDataFile.xml");
    R.I.P. 3.5" Floppy Drives
    "I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones." - Albert Einstein

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured