Click here to Skip to main content
15,667,885 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can anybody tell me how to bind a ComboBox to a MS Access database content?

Thanks in advance!
Updated 11-May-12 1:09am

Please see the discussion here: Using code to bind combo box to Access database[^].

That should help you along!


Share this answer
Maciej Los 11-May-12 16:28pm    
Good link, my 5!
hi replace your Access database file path in the connection string and give the table name and column name as required.
this is a sample example.
Private Sub FillCombo()
           Dim fillcon As New OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=path to access file.mdb;")
           Dim asql As String = ("SELECT * FROM Items ORDER BY ItemName")
           Dim da As New OleDbDataAdapter(asql, fillcon)
           Dim ds As New DataSet
           ItemNameCombo.ValueMember = "ItemName"
           ItemNameCombo.DataSource = ds.Tables(0)
           ItemNameCombo.SelectedIndex = 0
       Catch ex As Exception
           MsgBox("ERROR : " & ex.Message.ToString)
       End Try
   End Sub
Share this answer
Maciej Los 11-May-12 16:28pm    
Good example, my 5!
Well, by using a Connection String[^]!

The link above provides all info about connection string. Further info regarding the data communication can be read here: Accessing data with ADO.NET[^]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900