none
create report from XML RRS feed

  • Question

  • is it possible to use XML file as data source for Microsoft Reports Viewer? How?
    Jassim Rahma
    Tuesday, March 23, 2010 10:09 PM

All replies

  • helloooooo
    Jassim Rahma
    Wednesday, March 24, 2010 11:17 PM
  • To import the XML data:

    1. Create an XSD file from your XML file using the following command in Visual Studio Command Prompt: xsd.exe data.xml

    2. Then, use Add Existing Item to add the XSD file (e.g. data.xsd) to your project's root directory, which becomes a DataSet in your project. Then you can see and use data in the DataSet when designing your RDLC report.

    3. In your code, load the data into the LoadReport.DataSources collection. For example, the following code illustrates how to do this with a DataTable AdventureWorks2000DataSet.vSales after placing a ReportViewer control on your design surface:

    protected
    void Page_Load(object sender, System.EventArgs e)

    {

        ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local;

        ReportViewer1.LocalReport.ReportPath = "Report1.rdlc";

        ReportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("AdventureWorks2000DataSet_vSales", LoadData()));

    }

     

    private DataTable LoadData()

    {

        DataSet dataset = new DataSet();

        dataset.ReadXml("data.xml");

        return dataset.Tables[0];

    }


    Cephas Lin This posting is provided "AS IS" with no warranties.
    Thursday, March 25, 2010 2:38 PM
    Moderator