-
July 19th, 2011, 12:37 PM
#1
[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.
Code:
reportPath = reportPath + "\\" + this.Code + ".rpt";
_crystalReport.Load(reportPath, OpenReportMethod.OpenReportByTempCopy);
ParameterField paramField = new ParameterField();
ParameterDiscreteValue discreteVal;
_crystalReport.SummaryInfo.ReportTitle = this.Name;
_crystalReport.SummaryInfo.ReportComments = "";
for (int i = 0; i < _crystalReport.DataDefinition.ParameterFields.Count; i++)
{
ParameterFieldDefinition p = _crystalReport.DataDefinition.ParameterFields[i];
if (p.IsLinked())
continue;
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;
}
paramField.CurrentValues.Add(discreteVal);
_crystalReport.DataDefinition.ParameterFields[i].ApplyCurrentValues(paramField.CurrentValues);
}
Any input would be greatly appreciated.
Last edited by shollon; July 19th, 2011 at 12:41 PM.
-
July 19th, 2011, 12:54 PM
#2
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|