Populate listbox with a dataset

Posted on 2006-04-07
Last Modified: 2012-06-21
Hi Experts,

I want to know how to populate a listbox with a dataset.  I did the following code, but the listbox shows


I want to populate people's name in the listbox.  How to do that?

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim myCommand As New SqlDataAdapter("select * from tblUsers", objConn)

        Dim ds As DataSet = New DataSet
        myCommand.Fill(ds, "tblUsers")

        lbFrom.DataSource = ds.Tables("tblUsers").DefaultView

    End Sub

Question by:5281
    LVL 44

    Accepted Solution

    Hi 5281,

    Give the listbox some fields to use:


    For example, or substitute appropriate field names from your table.

    Unless you tell it what fields to bind to it cannot guess!

    Tim Cottee

    Author Comment

    Thank TimCottee,

    I didn't know what property I should use to display name.  Thank u very much.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    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…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    745 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

    15 Experts available now in Live!

    Get 1:1 Help Now