Pravin Ghadge

Pravin Ghadge

  • 562
  • 2.1k
  • 586.6k

Missing Parameterfield currrent value

Mar 2 2013 6:43 AM
Dear all,

I have created crystal report.
In that i have used command to fetch records from sql.
But When i am calling report through code. its giveing me runtime error "Missing Parameterfield currrent value"

string reppath = "";
                rd = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                string DOCENTRY = "";
                ParameterFields myparam = new ParameterFields();
                ParameterField param1 = new ParameterField();
                ParameterField param2 = new ParameterField();

                ParameterDiscreteValue dv1 = new ParameterDiscreteValue();
                ParameterDiscreteValue dv2 = new ParameterDiscreteValue();

                param1.ParameterFieldName = "@FromDate";
                param2.ParameterFieldName = "@ToDate";
                string dtpFrom = Convert.ToDateTime(DateTime.Today.Date.ToShortDateString()).ToString("yyyy/MM/dd");

                dv1.Value = dtpFrom;
                dv2.Value = dtpFrom;
                param1.CurrentValues.Add(dv1);
                myparam.Add(param1);

                param1.CurrentValues.Add(dv2);
                myparam.Add(param2);
                crystalReportViewer2.ParameterFieldInfo = myparam;

                reppath = ReportName;
                rd.Load(reppath);
                oDAL.OpenConnection();
              

                crystalReportViewer2.ReportSource = rd;
                crystalReportViewer2.ShowCloseButton = true;