DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2007
    Posts
    1

    Populating a combo box

    Hi All,

    Iam new to Vb.net trying to Populate a combo box.With a column in components table from ODBC.The ODBC is fromm ware house .

    My code is as follows

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
    Dim Cmd As.OdbcCommand
    Dim Con As Odbc.OdbcConnection
    Dim Sql As String = Nothing
    Dim Reader As Odbc.OdbcDataReader
    Dim ComboRow As Integer = -1
    Dim Columns As Integer = 0
    Dim Category As String = Nothing
    Dim db As DataSet

    CmbBoxMan.Items.Clear()

    db = DBEngine.Workspaces(0).OpenDatabase("kpidatabase", , "DSN=kpidatabase;UID=kpiuser;PWD=kpiuser")

    Sql = "SELECT [comp_itemnumber] FROM [componnets] ORDER BY [comp_itemnumber] Asc"
    Cmd = New Odbc.OdbCommand(Sql, Con)
    Con.Open()

    Reader = Cmd.ExecuteReader()
    While Reader.Read()
    For Columns = 0 To Reader.FieldCount - 1
    Category = Reader.Item(Columns) 'READ COLUMN FROM DATABASE
    Next
    CmbBoxMan.Items.Add(Category)
    ComboRow += 1
    End While
    Con.Close()


    End Sub

    Please reply

    Thanks in advance

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Take a look at the section, "Working With Combo Boxes and List Boxes" at this page: http://msdn2.microsoft.com/En-US/library/ms973824.aspx
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

Similar Threads

  1. Populating a Combo Box
    By ajames420 in forum VB Classic
    Replies: 0
    Last Post: 12-06-2005, 11:38 AM
  2. Replies: 1
    Last Post: 08-05-2002, 01:39 AM
  3. Populating a combo box through COM
    By Scott Cantwell in forum VB Classic
    Replies: 1
    Last Post: 03-29-2000, 06:52 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links