How to pass dataset to Crystal Viewer

Posted by Admin on 25-Aug-2009 07:27

I am trying to pass a dataset to the version 9 Crystal Viewer. I currently call the Crystal Viewer passing a rpt name to open like so:

CREATE 'CrystalRuntime.Report' chReport.
CREATE 'CrystalRuntime.Application' chApplication.
chReport = chApplication:OpenReport(cReportPath + prm-rpt).

chCtrlFrame:CrystalActiveXReportViewer:ReportSource = chReport.

/* View the report */

This works fine. However, the datasource is hardcoded in the rpt file, and I want to be able to pass a dataset.

I have heard of the use of the SetDataSource method, but I cannot find a sample of how it is used anywhere nor can I find it in the COM object viewer ...

Has anyone done this before or have a sample?

All Replies

Posted by Roger Blanchard on 25-Aug-2009 08:41


SetDataSource is a METHOD of iDatabase not iReport. So you would have to GET the Database from the report such as:

[ Com-Handle-Var = ] :Database.

and then use the SetDataSource on iDatabase such as:

NO-RETURN-VALUE : SetDataSource (
   -tableNumber ).

Now with that said I do recall having issues doing that in Crystal version 10 and 11. Give it a try.

This thread is closed