Solved

asp.net Populate combobox

Posted on 2007-11-30
3
1,163 Views
Last Modified: 2013-11-06
Here is my code, I'm wanting to fill a combobox from a column in an AS400 table:

Dim cn As iDB2Connection = New iDB2Connection("User ID=thegrinch;Password=elves;Data Source=1.1.1.1;Connection Timeout = 0")
        Dim cmd As iDB2Command
        Dim sqlstring As String
        sqlstring = "select domtshowf from air400.domest where domastat = 'H'"



        cn.Open()
        cmd = New iDB2Command(sqlstring, cn)
        Dim da As New iDB2DataAdapter(sqlstring, cn)
        Dim ds As New DataSet("FromShow")

        Try
            da.Fill(ds)
            cboShowFrom.DataSource = ds.Tables(0)
        Catch ex As Exception
            MessageBox.Show(ex.ToString)
        End Try
        cn.Close()
0
Comment
Question by:bergertime
3 Comments
 
LVL 15

Expert Comment

by:spprivate
Comment Utility
cboShowFrom.DataSource = ds.Tables(0)
cboShowFrom.Databind() --> You are missing this statement
0
 
LVL 9

Accepted Solution

by:
sognoct earned 500 total points
Comment Utility
cboShowFrom.DisplayMember = "domtshowf "
cboShowFrom.ValueMember = "domtshowf " <-- this can be also an ID if you add the primary key in the sqlstring
0
 
LVL 2

Author Closing Comment

by:bergertime
Comment Utility
displaymember was what I was looking for.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

763 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

11 Experts available now in Live!

Get 1:1 Help Now