[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

asp.net Populate combobox

Posted on 2007-11-30
3
Medium Priority
?
1,178 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 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
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 synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
Suggested Courses
Course of the Month20 days, 6 hours left to enroll

872 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