-
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
-
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
-
By ajames420 in forum VB Classic
Replies: 0
Last Post: 12-06-2005, 11:38 AM
-
Replies: 1
Last Post: 08-05-2002, 01:39 AM
-
By Scott Cantwell in forum VB Classic
Replies: 1
Last Post: 03-29-2000, 06:52 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
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
|
Bookmarks