Skip to Content
0
Former Member
Feb 20, 2011 at 11:34 AM

updating the Data source For Command Object

41 Views

How to change the datasource of a Command Table (embedded SQL statement you add to Crystal) during runtime? My scenario is that I have a test database & a datasource called "test" set up where I used the "Add Command" to add TSQL that pulls the data into the report -

I now need to point the report to the live database called "Production". I have to set the Parameter Fields and tried updating the table location using datasoureController but it throws the following exception...

java.lang.ClassCastException

at com.crystaldecisions.sdk.occa.report.data.Fields.add(Unknown Source)

at com.crystaldecisions.sdk.occa.report.lib.ReportSDKVector.copyTo(Unknown Source)

at com.crystaldecisions.sdk.occa.report.data.Procedure.copyTo(Unknown Source)

at com.crystaldecisions.sdk.occa.report.data.CommandTable.copyTo(Unknown Source)

at com.crystaldecisions.sdk.occa.report.data.CommandTable.clone(Unknown Source)

at com.crystaldecisions.sdk.occa.report.application.ad.if(Unknown Source)

at com.crystaldecisions.sdk.occa.report.application.DatabaseController.setTableLocation(Unknown Source)

at com.crystaldecisions.sdk.occa.report.application.DatabaseController.a(Unknown Source)

at com.crystaldecisions.sdk.occa.report.application.DatabaseController.setTableLocationEx(Unknown Source)

at com.crystaldecisions.reports.sdk.DatabaseController.setTableLocationEx(Unknown Source)

Here is the sample code

IProcedure procedure=(IProcedure) tables.getTable(i); ParameterFieldController paramFieldController=document.getDataDefController().getParameterFieldController(); Fields params=procedure.getParameters(); params.set(0, "142"); params.set(1, "5.0"); procedure.setParameters(params); procedure.setName(procedure.getName().toUpperCase()); procedure.setAlias(procedure.getAlias()); procedure.setQualifiedName(procedure.getName()); procedure.setConnectionInfo(connectionInfo); databaseController.setTableLocationEx(procedure,tables.getTable(i));

How should i do it?