We�re presently piloting the JRC packaged with Crystal Reports XI - Release-2.
We wanted to modify the selection formula of the report dynamically.
However, we came to know that presently this feature is only supported with the RAS and that JRC does not support this feature.
Hence, we decided to run the SQL query externally and set the data source for the report dynamically.
Mentioned below is a snippet of the code we�re using for achieving the same:
reportClientDocument.open("jrc_set_resultset_datasource/jrc_set_resultset_datasource.rpt", 0);
/*
* SQL query that can be used can be obtained by first creating a report
* directly off the desired datasource, and then in Crystal Reports, open the
* 'Database' > 'Show SQL Query' to see the SQL generated for the report.
*/
String query = (write a query to display information on the report depending on the selection criteria)
/*
* Call simple utility function that obtains
Java Result set that will be
* pushed into the report.
*/
ResultSet resultSet = getResultSetFromQuery(query, ResultSet.TYPE_SCROLL_INSENSITIVE);
String tableName = reportClientDocument.getDatabaseController().getDatabase().getTables().getTable(0).getName();
/*
* Push the Java Resultset into the report. This will then become the
* datasource of the report when the report itself is generated.
*/
reportClientDocument.getDatabaseController().setDataSource(resultSet, tableName , "resultTbl");
This approach works fine if the report has only one table configured. However, when more than one table is configured in the report with joins, it fails to display the report.
The queries we have are as follows:
1.Does JRC support multiple tables in a report with the approach suggested above?
2.If yes,
a.Do we need to specify result sets multiple times for each table in the report? If yes, how?
b.How do we specify the name of all the tables while setting the data source of the report document?
3.Is there any alternative way to set the selection formula of the report dynamically?
Kindly post a solution, its is very urgent.
[ June 29, 2007: Message edited by: vidhi majmudar ]