Link to home
Start Free TrialLog in
Avatar of Francis_B
Francis_B

asked on

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;
            }
Avatar of Brian Crowe
Brian Crowe
Flag of United States of America image

try...

crReportDocument.SetParameterValue("EventID", 166)
Avatar of Francis_B
Francis_B

ASKER

Hi BriCrowe,

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

Thanks,

Francis
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
... 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.
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