如何解决Crystal报告错误为"索引无效。 (HRESULT异常:0x8002000B(DISP_E_BADINDEX))"?

时间:2015-05-21 09:03:33

标签: c# wpf crystal-reports crystal-reports-2010

Hai在使用dateparameters加载wpf crystalreports时遇到错误"索引无效。 (来自HRESULT的异常:0x8002000B(DISP_E_BADINDEX))",如何解决这个问题?

            string dfrm1 = "";
            string dto1 = "";
            DateTime dateTime1a = datePicker1.SelectedDate.Value;
            dfrm1 = string.Format("{0} {1}:{2}:{3}", dateTime1a.ToShortDateString(), 00, 00, 01);
            DateTime dateTime2a = datePicker2.SelectedDate.Value;
            dto1 = string.Format("{0} {1}:{2}:{3}", dateTime2a.ToShortDateString(), 23, 59, 59);
            SqlConnection con = new SqlConnection(constring);
            con.Open();
            adp = new SqlDataAdapter("SELECT PatientID, PatientName],Blood_Group,City,Date FROM PatientTable Where Date Between'" + dfrm1 + "' and '" + dto1 + "'", con);
            adp.Fill(ds);
            string loc2 = AppDomain.CurrentDomain.BaseDirectory;
            orpt.Load(loc2 + "CrystalReport2.rpt");
            orpt.SetDataSource(ds.Tables[0]);
            orpt.SetParameterValue(0, dfrm1);//This line showing error as "Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))"
            orpt.SetParameterValue(1, dto1);
            rtg.crystalReportsViewer1.ViewerCore.ReportSource = orpt;

1 个答案:

答案 0 :(得分:0)

我有这个错误,我所做的是:

  1. 更新实体模型(* .edmx);
  2. 更新我的数据集(* .xsd);
  3. 更新报表数据库专家。

对我有用。