Solved

asp.net Populate combobox

Posted on 2007-11-30
3
1,165 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
New to Angular (read tutorial) - How do I bind to this table? 11 45
Cannot upload files above 1mb IIS7 11 39
Anyway to make "All" the default in the dropdown? 6 34
oracle 11g 23 48
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…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

911 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

20 Experts available now in Live!

Get 1:1 Help Now