I want to loop through some data I’m getting from a query using a label component.
This is my code to get the data and read it:
private void populatelblDesc()
{
conn.Open();
string query;
query = "select de.emp_username, poc.order_no , poc.company_id_no from dc_emp de, purch_order_carton poc";
OracleCommand cmd = new OracleCommand(query, conn);
OracleDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
lblDesc.Text = dr["emp_username"].ToString();
}
dr.Close();
conn.Close();
}
That query returns:
**EMP_USERNAME** **ORDER_NO** **COMPANY_ID_NO**
Werner 1 1
Chris 2 1
Mike 1 2
Marc 3 1
Now I want to use my NEXT button to go through the data. And each individual column in query must display in separate labels. So on load the 1st label will display “Werner”,2nd label “1”, 3d label “1”. Hitting next will display “Chris” in 1ste label, 2nd label “2”and 3d label “1” hitting next again will display “Mike” etc etc
Can someone help me with this please?
Save your Values in a list somewhere:
then use a integer value, starting with 0 and increase / decrease it by clicking next / prev
Add some validations if you are getting bellow 0 or greater than list size and you are done.