Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

17.02 The Push Model

Implementing the Push Model

Reports can either use the Pull Model or the Push Model for retrieving data. The Pull Model links to a data source and retrieves the data automatically. This was discussed in Chapter 13. The Push Model is based upon generating reports from a manually populated dataset. It requires you to create the dataset object, populate it with the appropriate data, and pass it to the report object for printing. You have complete control over how it works and can optimize the data connections. Since a dataset is designed to link to many types of data sources and you code the connection string, the Push Model gives you the flexibility to link to almost any type of data source as well as create custom datasets that link to proprietary data sources. This isn’t always possible with the Pull Model.

Using the Push Model results in the worst performance possible. Datasets are new to Crystal Reports and consequently they don’t have the best performance. The report has to process the data manually on the client. The performance might change in a future release, but for now Crystal Reports has been optimized to use the Pull Model with ODBC and OLE DB connections. The Push Model should only be used when the standard methods of connecting to data sources doesn’t work.

In certain circumstances, datasets can improve the scalability of ASP.NET applications. Datasets can be saved to the ASP.NET cache and used by multiple reports. For queries that either require a lot of processing by the server or return a large resultset, this results in a considerable improvement in performance. The first report runs as expected, but all reports after that benefit by having the dataset already populated and available in the web server’s memory. Use the Cache.Insert() method to save the DataSet object and use the Cache.Item() method to retrieve it.

The Push Model is more complicated than the Pull Model, and as a result there are more steps to learn. These steps are implemented in two stages. The first stage is creating the report for use with the Push Model. This consists of creating a dataset and specifying it as the report’s data source. Then design the report using the fields from this dataset. The second stage is writing the code to populate the dataset and pass it to the report. There are a total of four steps, which are listed and explained in detail next.

Stage Steps
Report Creation 1. Define the dataset schema file.
2. Build the report using the dataset schema file as the data source. Running the Report
3. Populate the dataset. 4. Bind the dataset to the report.