0

我收到错误“缺少参数值”。我浏览了许多帖子并尝试了所有帖子。

protected void Page_Load(object sender, EventArgs e)
    {
        PaystubParms pparms = new PaystubParms();

        pparms.periodstart = 20120316;
        pparms.periodend = 20120331;
        pparms.empno = "91065";
        pparms.checknbr = 2306;

        PaystubCrystalReportSource.ReportDocument.SetDatabaseLogon("Abra_Reports","123456","Tsysmas","AbraHrms_Live");


        ParameterField pfield0 = PaystubCrystalReportViewer.ParameterFieldInfo[0];
        ParameterDiscreteValue pfield0val = new ParameterDiscreteValue();

        pfield0val.Value = pparms.periodstart;
        pfield0.CurrentValues.Add(pfield0val);
        //-------------------------------------------------------------------------
        ParameterField pfield1 = PaystubCrystalReportViewer.ParameterFieldInfo[1];
        ParameterDiscreteValue pfield1val = new ParameterDiscreteValue();

        pfield1val.Value = pparms.periodend;
        pfield1.CurrentValues.Add(pfield1val);

        //-------------------------------------------------------------------------
        ParameterField pfield2 = PaystubCrystalReportViewer.ParameterFieldInfo[2];
        ParameterDiscreteValue pfield2val = new ParameterDiscreteValue();

        pfield2val.Value = pparms.empno;
        pfield2.CurrentValues.Add(pfield1val);
        //-------------------------------------------------------------------------
        ParameterField pfield3 = PaystubCrystalReportViewer.ParameterFieldInfo[3];
        ParameterDiscreteValue pfield3val = new ParameterDiscreteValue();

        pfield3val.Value = pparms.periodstart;
        pfield3.CurrentValues.Add(pfield1val);



        PaystubCrystalReportSource.ReportDocument.SetParameterValue(0, pfield0.CurrentValues.Add(pfield0val));

        *******************************************************************
        I have also tried
        PaystubCrystalReportSource.ReportDocument.SetParameterValue(0, pparms.periodstart);
        *******************************************************************************

        PaystubCrystalReportSource.ReportDocument.SetParameterValue(1, pfield1.CurrentValues.Add(pfield1val));
        PaystubCrystalReportSource.ReportDocument.SetParameterValue(2, pfield2.CurrentValues.Add(pfield2val));
        PaystubCrystalReportSource.ReportDocument.SetParameterValue(3, pfield3.CurrentValues.Add(pfield3val));

        PaystubCrystalReportViewer.ReportSource = PaystubCrystalReportSource;

    }
4

1 回答 1

0

确保所有参数都是 Crystal 期望的类型。

有时传递错误类型的参数会导致“缺少参数”错误。例如,为整数参数传递十进制值。

于 2012-04-27T18:22:20.553 回答