Populate listbox with a dataset

Posted on 2006-04-07
Medium Priority
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 43

Accepted Solution

TimCottee earned 1000 total points
ID: 16401191
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

ID: 16401386
Thank TimCottee,

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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

839 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