Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplay database value on label in a table
    text
    copied!<p>I'm trying to use datareader to display out specific value from specific table in the database. As you can see from my sql query, i uses datas from 3 separate tables and memberreportid and username has a PK and FK r/s. Unfortunately, i wasn't able to display out the value i wanted as stated below. </p> <p>This is the error i recevied</p> <p><strong>IndexOutOfRangeException was unhandled by user code</strong></p> <p>I comment the display out value codes line by line and indeed all of received the above error</p> <p>Here are my codes.</p> <pre><code>protected void DDLCase_SelectedIndexChanged(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source = localhost; Initial Catalog = project; Integrated Security = SSPI"); con.Open(); SqlCommand cm = new SqlCommand("Select * from MemberReport mr, PoliceReport pr, LoginRegisterOthers lro where pr.memberreportid = '" + DDLCase.SelectedItem.Text + "' and mr.memberreportid=pr.memberreportid and lro.username=mr.username and caseprogress='settled'", con); SqlDataReader dr; dr = cm.ExecuteReader(); if (dr.Read()) { lblFullName.Text = dr["lro.fullname"].ToString(); lblContact.Text = dr["lro.contact"].ToString(); lblTOC.Text = dr["mr.typeofcrime"].ToString(); lblLocation.Text = dr["mr.location"].ToString(); lblCRDT.Text = dr["mr.CRdatetime"].ToString(); lblPicture.Text = dr["picture"].ToString(); lblAssign.Text = dr["pr.policeid"].ToString(); lblPRDT.Text = dr["pr.PRdatetime"].ToString(); lblCR.Text = dr["mr.citizenreport"].ToString(); lblPR.Text = dr["pr.policereport"].ToString(); } con.Close(); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload