Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass Parameters to report issue! Help

Status
Not open for further replies.

aspnet

Programmer
Oct 9, 2003
1
0
0
CA
I feel very frustrated in passing parameters to crystal report and try to get dynamic report by user input values
I am posting codes here and please advice me your opinion...

Thanks advance!!!

<%

IInfoStore iStore = null;
IInfoObjects oInfoObjects = null;
IInfoObject oInfoObject = null;
IEnterpriseSession es = null;

es = (IEnterpriseSession)session.getAttribute(&quot;CE_Session&quot;);

iStore = (IInfoStore)es.getService(&quot;&quot;, &quot;InfoStore&quot;);
oInfoObjects = (IInfoObjects)iStore.query(&quot;Select * from CI_INFOOBJECTS Where SI_PROGID = 'CrystalEnterprise.Report' And SI_INSTANCE = 0 And SI_NAME='rptBrandConsumersUSA5'&quot;);

oInfoObject = (IInfoObject)oInfoObjects.get(0);

//cast the InfoObject as a Report Object
IReport oReport = (IReport)oInfoObject;

List paramList = oReport.getReportParameters();

//create a new Fields collection to hold the
parameterfield

Fields params = new Fields();

try
{

for (int x=0; x<oReport.getReportParameters().size(); x++)
{
//get current parameter object
IReportParameter oParam = (IReportParameter)paramList.get(x);

ParameterField newParam = oParam.getParameterField();

//get parameter name

String paramName = newParam.getName();

//declare a new parameter value object
ParameterFieldDiscreteValue paramValue = new ParameterFieldDiscreteValue();

//retrieve user input value
String strValue = request.getParameter(paramName);

paramValue.setValue(strValue);

newParam.getCurrentValues().add(paramValue);
params.add(newParam);

}
}
catch(Exception e){
e.printStackTrace();
}

//set the Fields collection to the viewer
viewer.setParameterFields(params);

 
Are the parameters being passed in very long (> 256 chars)? There is a problem, with a patch though I forget which one, with long parameters. Actually even with that patch I kept running into problems when parameter sizes rose above 500 characters. Eventually, on Crystal's tech support recommendation, I retrieved the data myself and used ReportClientDocument.DatabaseController.AddDataSource and .SetDataSource to attach an ADO record set to the report before viewing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top