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;
答案 0 :(得分:0)
我有这个错误,我所做的是:
对我有用。