Sunday, February 1, 2009

How to read data from XML file to Crystal Report in C#

private void Form1_Load_1(object sender, EventArgs e)
{
string xmlFilename = "C:\\Project\\XMLCrystalReport\\books.xml";

DataSet newDataSet = new DataSet();
// read the XML document into the DataSet.
newDataSet.ReadXml(xmlFilename);

ReportDocument customerReport = new ReportDocument();
customerReport.Load(@"C:\Project\XMLCrystalReport\collection.rpt");
customerReport.SetDataSource(newDataSet);
crystalReportViewer1.ReportSource = customerReport;
}