This article is intended to illustrate the benefits of using disconnected connection in crystal reports. In connected mode the performance of the reports is very big issue when the size of the database gets bigger especially in web application the response time is very poor.
Xml schema is now a standard way of moving data between the systems. Xml schema are extensible for future use, this property is also very useful when we have changes on the db side and report side.
By using the benefits of ADO.NET we can also made desired changes in memory before passing to the reports.
The sample application is an example in which things has been explained in very simple manner. Complex scenario can be driven from it. This application is running on .net framework 2.0 and Crystal report 2008.
Setting Data source location
In crystal report 2008 select database location option from Database menu. Then click on the ADO.NET option.
Then design the application in standard way, please download source file and view sample report file with this article
Application logic.
Run the executable application and select respective files
The libraries must be included in namespace. The crystalDecisions.CrystalReports.Engine namespace provides support for the report engine.
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
In DataSet object give the names of the table defined in the XSD File. I am using only a single table but there can be multiple tables in schema so please don't forget to define the table name in dataset while populating DataSet for respective table.
dsSource = new DataSet("TableA");
Populate the dataset with the xml source file. Reads XML schema and data into the System.Data.DataSet using the specified file.
dsSource.ReadXml(strSourceFile);
The report document object represents a report and contains properties and methods to define, format, load, export, and print the report e.g,
reportDoc = new ReportDocument();
reportDoc.Load(strFileName);
After finalizing above steps it time to pass it to the crystal report viewer object. The CrystalReportViewer control allows a Crystal Report to be viewed in an application. The ReportSource property is used to set which report is to be viewed. Once this property is set, the report will be shown in the viewer. The source of the report can either be a ReportDocument, a path to the report file, or a strongly typed report.
reportDoc.SetDataSource(dsSource);
frmShowReport.crViewer.ReportSource = reportDoc;
frmShowReport.ShowDialog();
Thanks