Solved

asp.net Populate combobox

Posted on 2007-11-30
3
1,169 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
ID: 20383311
cboShowFrom.DataSource = ds.Tables(0)
cboShowFrom.Databind() --> You are missing this statement
0
 
LVL 9

Accepted Solution

by:
sognoct earned 500 total points
ID: 20383904
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
ID: 31411952
displaymember was what I was looking for.
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

726 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