Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8949611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:15:32+00:00 2026-06-15T13:15:32+00:00

I want to loop through some data I’m getting from a query using a

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T13:15:33+00:00Added an answer on June 15, 2026 at 1:15 pm

    Save your Values in a list somewhere:

    List<String> LabelTextList = new List<String>();
    private void populatelblDesc() 
    {
        conn.Open();
        query = "select emp_username from dc_emp";
        OracleCommand cmd = new OracleCommand(query, conn);
        OracleDataReader dr = cmd.ExecuteReader();
        while (dr.Read())
        {
            this.LabelTextList.add(dr["emp_username"].ToString());
        }
        dr.Close();
        conn.Close();
    }
    

    then use a integer value, starting with 0 and increase / decrease it by clicking next / prev

    int i = 0;
    public void next(){
        if (i+1 < this.LabelTextList.Count())
           lblText.text = this.LabelTextList[++i];
    }
    public void prev(){
        if (i-1 >= 0)
            lblText.text = this.LabelTextList[--i];
    }
    

    Add some validations if you are getting bellow 0 or greater than list size and you are done.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hi i want to loop through some tr's like this . <tr> <td> <input
I want to loop through the rows of a data.table and calculate an average
In C, I want to loop through an array in this order for(int z
Pointer related question. I'm going through some example code that currently reads in data
I have an application I'm working on where I want to loop through some
I want to send some data to an Arduino through pyserial in Python. All
I want to loop multiple times through my query results, and I have 2
I want to loop through the checkboxgroup 'locationthemes' and build a string with all
I want to loop through the controls on a UserControl and set a property
I want to loop through a database of documents and calculate a pairwise comparison

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.