July 19th, 2011, 01:37 PM
[RESOLVED] Passing Params to Crystal Reports
I'm creating a new Crystal Report. The binding is done via Dataset and it accepts params. We have existing code that applies params. These existing reports bind directly to a SPROC and they have Params that go to the SPROC and some that are just local to the report.
However, with the Dataset report, i keep getting an error "Missing parameter values" when trying to export the report to PDF.
I've tried removing ALL params and executing the report and it works just fine. Once I added a param to the report, i start seeing this error.
here is the code snippet of how the params are being set.
Any input would be greatly appreciated.
reportPath = reportPath + "\\" + this.Code + ".rpt";
ParameterField paramField = new ParameterField();
_crystalReport.SummaryInfo.ReportTitle = this.Name;
_crystalReport.SummaryInfo.ReportComments = "";
for (int i = 0; i < _crystalReport.DataDefinition.ParameterFields.Count; i++)
ParameterFieldDefinition p = _crystalReport.DataDefinition.ParameterFields[i];
string strValue = "";
strValue = GetReportValue(p.Name, reportParameters);
paramField = new ParameterField();
discreteVal = new ParameterDiscreteValue();
paramField.ParameterFieldName = p.Name;
if (strValue != "" || p.Name == "ColdStorageLine")
discreteVal.Value = strValue;
Last edited by shollon; July 19th, 2011 at 01:41 PM.
July 19th, 2011, 01:54 PM
Re: [RESOLVED] Passing Params to Crystal Reports
Apparently, you have to set the Datasource BEFORE you apply the parameters. Setting the datasource beforehand apparently clears the params.
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.