我收到错误“缺少参数值”。我浏览了许多帖子并尝试了所有帖子。
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;
}