How to pass parameters to the stored procedure in the crystal report data source ...

zhaozj2021-02-16  58

The crystal report will automatically establish a "parameter field" for each "parameter" in the stored procedure, so this has become a problem that the parameter is assigned to the parameter ...

Customize the parameter field

[Visual Basic] 'The declaration passed the parameters to the variable required by the viewer control. Dim paramfields as new parameterfields () Dim paramfield as new parameterfield () DIM Discreteval as new parameterdiscretevalue () Dim Rangeval As new parameterRangeValue ()

'The first parameter is a discrete parameter having multiple values.

'Set the name of the parameter field, it must be "consistent with the parameters in the report. PARAMFIELD.PARAMELDNAME = "Customer Name"

'Set the first discrete value and pass it to this parameter discreteval.Value = "AIC Childrens" paramfield.currentValues.Add (Discreteval)

'Set the second discrete value and pass it to this parameter. The 'Discreteval variable is set to a new value, so that the previous settings will not be overwritten. Discreteval = new parameterdiscretevalue () discreteval.value = "aruba sport" paramfield.currentvalues.add (discreteval)

'Add this parameter to the parameter field collection. Paramfields.Add (paramfield)

'The second parameter is the zone value. The PARAMFIELD variable 'is set to a new value, so that the previous settings will not be overwritten. Paramfield = new parameterfield ()

'Set the name of the parameter field, it must be "consistent with the parameters in the report. PARAMFIELD.PARAMELDNAME = "Customer ID"

'Set the start value of the area and the end value and pass the area to this parameter. Rangeval.StartValue = 42rangeVal.endvalue = 72Paramfield.currentVales.Add (Rangeval)

'Add the second parameter to the parameter field collection. Paramfields.Add (paramfield)

'Place the parameter field into the viewer control. CrystalReportViewer1.ParameterfieldInfo = paramfields

CrystalReportViewer1.Reportsource = "C: / report / my report.rpt"

[C #] // The declaration passes the parameters to the variable required for the // viewer control. ParameterFields paramFields = new ParameterFields (); ParameterField paramField = new ParameterField (); ParameterDiscreteValue discreteVal = new ParameterDiscreteValue (); ParameterRangeValue rangeVal = new ParameterRangeValue ();

// The first parameter is a discrete parameter having a plurality of values.

/ / Set the name of the parameter field, it must / / and match the parameters in the report. PARAMFIELD.PARAMELDNAME = "Customer Name";

/ / Set the first discrete value and pass it to this parameter. DiscreteVal.Value = "AIC Childrens"; paramfield.currentVales.Add (discreteval); // Set the second discrete value and pass it to this parameter. // Discreteval variable is set to a new value, so that previous settings // will not be overwritten. Discreteval = new parameterdiscretevalue (); discreteval.value = "aruba sport"; paramfield.currentvalues.add (discreteval);

// Add this parameter to the parameter field collection. Paramfields.Add (paramfield);

// The second parameter is the zone value. PARAMFIELD variable // is set to a new value, so that the previous settings will not be overwritten. Paramfield = new parameterfield ();

/ / Set the name of the parameter field, it must / / and match the parameters in the report. PARAMFIELD.PARAMELDNAME = "Customer ID";

// Set the start value and end value of the range and pass the range to // this parameter. Rangeval.StartValue = 42; RangeVal.endValue = 72; paramfield.currentVales.add (Rangeval);

// Add the second parameter to the parameter field collection. Paramfields.Add (paramfield);

// Place the parameter field into the viewer control. CrystalReportViewer1.ParameterfieldInfo = paramfields; [C ] // The declaration passes the parameters to the variable required to // viewer control. ParameterFields * paramFields = new ParameterFields (); ParameterField * paramField = new ParameterField (); ParameterDiscreteValue * discreteVal = new ParameterDiscreteValue (); ParameterRangeValue * rangeVal = new ParameterRangeValue ();

// The first parameter is a discrete parameter having a plurality of values. / / Set the name of the parameter field, it must / / and match the parameters in the report. Paramfield-> ParameterfieldName = "Customer Name";

/ / Set the first discrete value and pass it to this parameter. String * Val = "AIC Childrens"; discreteval-> value = val; paramfield-> currentValues-> add (discreteval);

/ / Set the second discrete value and pass it to this parameter. // Discreteval variable is set to a new value, so that previous settings // will not be overwritten. Discreteval = new parameterdiscretevalue (); val = "aruba sport"; discreteval-> value = val; paramfield-> currentValues-> add (discreteval);

// Add this parameter to the parameter field collection. PARAMFIELDS-> Add (paramfield);

// The second parameter is the zone value. PARAMFIELD variable // is set to a new value, so that the previous settings will not be overwritten. Paramfield = new parameterfield (); // Set the name of the parameter field, it must / / and match the parameters in the report. Paramfield-> parameterfieldname = "Customer ID";

// Set the start value and end value of the range and pass the range to // this parameter. Rangeval-> StartValue = __box (42); Rangeval-> endValue = __box (72); paramfield-> currentVales-> add (rangeval);

// Add the second parameter to the parameter field collection. PARAMFIELDS-> Add (paramfield);

// Place the parameter field into the viewer control. CrystalReportViewer1-> ParameterfieldInfo = paramfields;

CrystalReportViewer1-> EXPORTREPORT ();

转载请注明原文地址:https://www.9cbs.com/read-22480.html

New Post(0)