How do I populate a combo box with datareader where I have a value to display and a value to be read

Posted on 2009-04-17
Last Modified: 2012-05-06
I am using a datareader to load two fields:

Region code : I need to use the code to save it later in another table
Region Name: I need to display the region name in the combo box

I'm trying to use "tag" to save the regioncode which is my first field...It's not working
please help
dr = datareader <-

cboregioncode <- combo box


       While dr.Read()


            cboRegionCode.Tag = dr(0)

        End While

        dr = Nothing

Open in new window

Question by:pachecosita
    LVL 10

    Accepted Solution


    cboRegionCode.Items.Add(New ListItem(dr(1), dr(0)))
    LVL 48

    Expert Comment

    If you have a datasource like a SqlDataReader, why don't you do something like this:

    Me.cboregioncode.DataSource = dr
    Me.cboregioncode.DisplayMember = "Region Name (Field Name)"
    Me.cboregioncode.ValueMember = "Region Code (Field Name)"

    Author Closing Comment

    I found out the best one to use is Dataset!

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Flash ( has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
    More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now