Fist of all, create an MS Access database, and name it as db. Add a new table to it:
Table name: Positions
Fields:
ID (number, primary key)
Position (text)
Create a new vb.net windows project; add a new form to it.
Add a combobox to the form, name is as cbPositions.

Switch to View Code mode, copy and paste the following sub:
Sub FillComboBox()
Dim pk(0) As DataColumn
Dim dt As New DataTable
Dim strconn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Power\Desktop\db.mdb"
Dim conn As OleDbConnection
Dim da As OleDbDataAdapter
Try
conn = New OleDbConnection(strconn)
da = New OleDbDataAdapter("Select * from positions", conn)
dt.Clear()
da.Fill(dt)
pk(0) = dt.Columns("ID")
dt.PrimaryKey = pk
conn.Close()
Me.cbPositions.DataSource = dt
Me.cbPositions.DisplayMember = "position" ' display the position name in the combo
Me.cbPositions.ValueMember = "ID" ' set the ID to be the value of each member
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
You can call this sub in the Form Load Event:
Private Sub frm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
FillComboBox()
End Sub
You may see the same exampme in C#, Bind an ADO.NET DataTable to a Combobox in C#
That’s it!




