首页 文章

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

提问于
浏览
1

Hai我在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

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

    • 更新实体模型(* .edmx);

    • 更新我的DataSet(* .xsd);

    • 更新报告DataBase Expert .

    它对我有用 .

相关问题