?
Solved

asp.net Populate combobox

Posted on 2007-11-30
3
Medium Priority
?
1,174 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
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.
Suggested Courses
Course of the Month10 days, 16 hours left to enroll

770 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