Builder.com looks at the ways the Crystal Reports engine acquires the data it uses to generate reports and compare the trade-offs you'll make for using each method.

If you've decided to use Crystal Reports as your data source in .NET, it's important to plan your data access strategy carefully. Your choice of data access strategy will directly affect your ability to update the reports and manage their distribution.

Push or pull?
You basically have two choices when acquiring data:

  • Pull it from a data source.
  • Push a dataset to the report.

With the pull method, the Crystal Reports engine pulls the requested data from a connected data source. Crystal Reports can use industry standard OLE DB or ODBC drivers to connect to a database, or it can use specialised drivers (included with the package) that query an Excel worksheet or an Access database. The developer starts one of the built-in wizards, selects data sources from which to pull data, and then selects the tables and fields to use in the report. Since this activity is completed at design time, the user doesn't need to do anything at run time for the reports to access the necessary data.

The push method uses a different procedure to give the reporting engine access to the data. In this mode, the developer sets up the tables and fields that the report uses in the report designer as normal. But instead of hard-coding the data sources, the developer builds a dataset at run time and passes it to the report. If the .NET project uses typed datasets, the developer can use those as the model to embed table definitions into the report. At run time, the developer simply populates a dataset and passes it to the report engine using the SetDataSource method.

There are two objects that expose the SetDataSource method. The ReportDocument class is the encapsulation of the report itself; it exposes SetDataSource as a method. You should use SetDataSource from the report object when your dataset contains all the tables and they match with the definitions inside the report. The report object also exposes a database property that has a tables collection. The Table class also has a SetDataSource method. You can fill the report's tables directly by retrieving the appropriate table, calling SetDataSource, and passing the dataset with the appropriate records directly to it.

The choice of pull or push data access is not mutually exclusive. The developer can mix these methods in a single report, allowing the Crystal Reports engine to pull data from different data sources at run time. But you must make your decision to use either or both methods while considering the context of each method's limitations.

Making a push or pull decision
When deciding which data access method to use, consider the trade-offs. One of the most important considerations in adding reporting capability to any project is how the decision will affect maintainability. Using the pull access method requires the developer to put information about the data source into a report directly. If the details need to be changed, the reports affected will also have to be changed and potentially redeployed. Using datasets with the push model requires that only the report know the schema for the data. It's up to the developer to gather the necessary data and make sure it's accessible in the data access layer at run time.

On the other hand, the push model requires more work to set up. The developer has to set up database connections, run the necessary queries, and pass the data to the report using the SetDataSource method. Push model reports are also more time consuming for developers to create because they have to define the schema with little help from the underlying data source. Using typed datasets makes the process somewhat simpler since the report experts can extract the information from the schema file. Otherwise, the developer has to create the schema using a field or data definition file and then load it into the report at design time. The push model also requires more interaction between the view and the report.

The final consideration for using these models involves the choice of viewer. Since a report created with the pull model has all data source definitions embedded, it can be used with the Windows or Web report viewer. A report created using the push model, however, can be viewed only by using a program designed to collect and expose the data for it.

Consider such trade-offs when selecting a data acquisition model; doing so can help you make more intelligent decisions about how to architect a more effective reporting mechanism using Crystal Reports.

Related links

Comments

1

Willson - 01/02/07

Its good information but little suffiient.well its nice.

» Report offensive content

2

Johnykutty P.C. - 09/07/07

this is very helpful for understant the crystal reports.

» Report offensive content

3

Gandhi Basnet - 10/08/07

Thank you very much about the information. It is fantastic coz' I was wandering which option to follow for the crystal report

» Report offensive content

4

Gandhi Basnet - 10/08/07

Thank you very much about the information. It is fantastic coz' I was wandering which option to follow for the crystal report

» Report offensive content

5

Gandhi Basnet - 10/08/07

But still I wanna know : whether I must use the Dataset directly for the report or the schema file ?

» Report offensive content

6

gandhibasnet - 21/09/07

In Sql server, I want to retrieve all the table names where I have used the Identity property. Can I ?

» Report offensive content

7

Ashokkumar - 01/12/07

Very nice and brief explanation made me understood about these methods. Thank you very much for this info.

» Report offensive content

Leave a comment

You must read and type the 6 chars within 0..9 and A..F

* indicates mandatory fields.

7

Ashokkumar - 12/01/07

Very nice and brief explanation made me understood about these methods. Thank you very much for this info. ... more

6

gandhibasnet - 21/09/07

In Sql server, I want to retrieve all the table names where I have used the Identity property. Can I ? ... more

5

Gandhi Basnet - 08/10/07

But still I wanna know : whether I must use the Dataset directly for the report or the schema file ? ... more

Log in


Sign up | Forgot your password?

  • Staff Aussies to pay more for Win 7

    If you are looking to make some money in these troubled times, perhaps importing copies of Windows 7 could be for you. Read more »

    -- posted by Staff

  • Staff Firefox: Greens want it, 3.5rc2 not up to par

    This week's roundup looks at the situation surrounding a campaign to change Outlook HTML renderer, a Greens MP wants to install Firefox but is restricted and all the photos from the iPhone 3GS launch. Read more »

    -- posted by Staff

  • Chris Duckett Microsoft misses the Outlook point

    Ask designers which mail program is the bane of their existence, and you'll find that Outlook tops the list. The reason why the most popular email reader is also the most painful is simple: it uses Word to render HTML emails. Read more »

    -- posted by Chris Duckett

Most popular tags

What's on?