fergus

fergus

  • 1.2k
  • 232
  • 1k

i think i need a loop but how?

Mar 27 2024 12:50 PM

hi there,

i have managed to pull in data from my sql table into my asp.net page. i am only getting one row. how can i get all rows to display that are containg in the table.

i have this so far:

 


                myCon.Open();
                string qry2 = "select client_ref, crosk_ref, client_name, section_name from md_overall_temp where client_code='" + lblRefNum.Text + "'";
                SqlCommand cmd2 = new SqlCommand(qry2, myCon);
                SqlDataAdapter adapter2 = new SqlDataAdapter(cmd2);
                DataTable dt2 = new DataTable();
                adapter2.Fill(dt2);
                if (dt2.Rows.Count > 0)
                {
                    string clientRef = dt2.Rows[3]["Client_ref"].ToString();
                    CLIENTREF.Text = clientRef;
                    string croskRef = dt2.Rows[3]["Crosk_ref"].ToString();
                    CROSKREF.Text = croskRef;
                    string clientName  = dt2.Rows[3]["Client_name"].ToString();
                    CLIENTNAME.Text = clientName;
                    string section_name = dt2.Rows[3]["Section_name"].ToString();
                    SECTIONNAME.Text = section_name;
                }
                else
                {
                    CLIENTREF.Text = "No record found!";
                }
                myCon.Close();

 

 

 


Answers (5)