Crystal Reports 10: The Complete Reference

Crystal Reports Custom Data Sources

Crystal Reports includes additional capabilities to base reports on data sources you create in a custom-designed application. These data sources (sometimes referred to as Active Data Sources) are a departure from typical relational databases, such as Microsoft Access or Oracle. Custom data sources are often used to provide data to Crystal Reports from another program that s running separately on your PC. Such separate programs might be connecting to real-time instrumentation (such as measuring devices). Or, you may be designing a report to integrate within a custom Windows program and wish to connect to a data source exposed by the application.

These custom data sources appear in the Database Expert:

To connect to a custom data source, begin a new report as you normally would with a relational database. You may use a wizard or the Blank Report option. In either case, expand the Create New Connection category of the Database Expert to proceed. You ll see entries for each of the active data sources (if you don t see the data source you need, you may need to re-run Crystal Reports setup and add the data source). Click the plus sign next to the desired data source.

If, for example, you choose COM Connectivity to connect to an exposed COM automation server, you ll be presented with a dialog box asking you to specify the Program ID of the automation server. Type in the exact name of the COM data source (that you either specified when you developed the program that exposes the automation server, or the name given you by the program s designer).

Once you ve supplied the proper Program ID, click Finish. The Database Expert will return with a new entry in the Available Data Sources list (record sets returned by active data sources will often appear similar to SQL stored procedures). Select the data source or sources you wish to base the report on and add them to the Selected Tables list. If a data source requires a parameter value to be supplied, you ll be prompted for it much as you are prompted when using a parameterized stored procedure.

Supply any necessary parameters and click OK. Once you ve added the active data source, close the Database Expert. Fields exposed by the active data source will appear in the Field Explorer as with any other standard data source.

Tip  

For more information on custom data sources, including sample code to create programs that expose data in this fashion, consult the online Technical Reference from the Crystal Reports program CD.

Категории