How can I populate a Bind a combo box to data stored in a table (tblActivity) using ADO via code?
so far I have been able to connect to the database, the code below represent my progress so far
Code:
'created the variable conn that represents a new instance of
'OleDb.Connection Object
Dim conn As New OleDb.OleDbConnection
'created the variable DataSet that represents a new instance of the object DataSet
Dim DataSet As New DataSet
'create the variable DataAdapter as an instance of OleDB.OleDbDataApapter
Dim DataAdapter As OleDb.OleDbDataAdapter
Dim sql As String
Public Sub PopulateActivity()
conn.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source =" _
& Application.StartupPath & "\TSDB.mdb"
conn.Open()
sql = "SELECT Activity FROM tblActivity"
DataAdapter = New OleDb.OleDbDataAdapter(sql, conn)
DataAdapter.Fill(DataSet, "Activity")
conn.Close()
End Sub
