I want to pass a parameter from visual studion WinForm to crystalReport I have done this:
rptDoc.SetDataSource(dt);
ParameterFields paramFields = new ParameterFields();
ParameterField paramField = new ParameterField();
ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();
paramField = new ParameterField();
paramDiscreteValue = new ParameterDiscreteValue();
paramField.Name = "CableRevision";
paramDiscreteValue.Value = currentInfo.CableRevision;
paramField.CurrentValues.Add(paramDiscreteValue);
paramFields.Add(paramField);
crystalReportViewer1.ReportSource = rptDoc;
and also i have defined a Parameter Field of Field Explorer in Report Named "@CableRevision". should it be Dynamic or Static? I have tried both but every time a dialog box and asks for CableRevision Parametere Value. i dont wan't that dialog box get the value because i want to pass the value by
paramDiscreteValue.Value = currentInfo.CableRevision;
is that wrong?
Your paramField didn't connect to
rptDocyet.You may try this code instead
rptDoc.DataDefinition.ParameterFieldswill return all parameters in the rptDoc. Then you have to set value for each parameter as inswitchscope.This is sample for many patameters in report, if you have only on parameter, you don't need to have
switchscope, just have this line instead