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
                  //
                  InitializeComponent();

                  //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
                  crParameterValues.Add(crParameterDiscreteValue);

                  //All current parameter values must be applied for the parameter field.
                  crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);

                  //Set the viewer to the report object to be previewed.
                  crystalRV.ReportSource = crReportDocument;
            }
Francis_BAsked:
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.

mlmcc
0
 
Brian CroweDatabase AdministratorCommented:
try...

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

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

Thanks,

Francis
0
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
0
 
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!)

Francis.
0
 
mlmccCommented:
I bet SAVE DATA WITH REPORT is the default.  To change that
Open Crystal with no report
Click FILE --> OPTIONS
Uncheck the SAVE DATA WITH REPORT option

Glad i could help

mlmcc
0
All Courses

From novice to tech pro — start learning today.