Discrete Parameter not Working with .NET (C#)

Hi Experts,

Hi have a form that is made of a Crystal Report Viewer, and I'm trying to load a report into it.
The report loads, but witouth the Parameter field set to the value I assign in the code ... And if I hit Refresh, it will prompt me for the Discrete Value ...

Here's the code I use :

public ShippingReportViewer()
                  // Required for Windows Form Designer support

                  //Create an instance of the strongly-typed report object
                  crReportDocument = new FulFill();
                  //Get the collection of parameters from the report
                  crParameterFieldDefinitions = crReportDocument.DataDefinition.ParameterFields;
                  //Access the specified parameter from the collection
                  crParameterFieldDefinition = crParameterFieldDefinitions["EventID"]; //This is the parameter in the report, a Number

                  //Get the current values from the parameter field.  At this point
                  //there are zero values set.
                  crParameterValues = crParameterFieldDefinition.CurrentValues;

                  //Set the current values for the parameter field
                  crParameterDiscreteValue = new ParameterDiscreteValue();
                  crParameterDiscreteValue.Value = 166; //I know, it's static, but its to test !!!

                  //Add the first current value for the parameter field

                  //All current parameter values must be applied for the parameter field.

                  //Set the viewer to the report object to be previewed.
                  crystalRV.ReportSource = crReportDocument;
Who is Participating?
mlmccConnect With a Mentor Commented:
Check the report for SAVED DATA

Open the report
Click FILE
Ensure SAVE DATA WITH REPORT is not checked.

Brian CroweDatabase AdministratorCommented:

crReportDocument.SetParameterValue("EventID", 166)
Francis_BAuthor Commented:
Hi BriCrowe,

hum.. this command does not exist when I type crReportDocument ... can it be a version problem?


Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Francis_BAuthor Commented:
mlmcc - I have both Crystal Reports 9.2 and the version included in .NET ... Now this report has been created directly in .NET,
but I noticed that the VERSION property of the CRYSTALREPORTS.ENGINE reference is 9.2.3 ... Can it affect something?

- I will try the SAVE DATA WITH REPORT not checked issue now, using the CrystalReports 9.2.3 (this is not availlable in CrystalReport .NET, I think ...)

Thanks for your help
Francis_BAuthor Commented:
... and you were RIGHT !!! The SAVE DATA WITH REPORT was checked !

Great ! I can now call this report with the associated Event ID !

Thanks alot mlmcc, this was a tricky one ! (well.....for me!)

I bet SAVE DATA WITH REPORT is the default.  To change that
Open Crystal with no report
Uncheck the SAVE DATA WITH REPORT option

Glad i could help

All Courses

From novice to tech pro — start learning today.