Hai i got error in wpf crystalreports while loading with dateparameters as "Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))",how to solve this?
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;
I had this error, what I did was:
it worked for me.
User contributions licensed under CC BY-SA 3.0