Hi, this is totally off the top of my head so excuse any errors but should put you on the right path.
There are a number of ways to do this here's one
VB Code:
' Database connection object
Dim oConn as new oledb.oledbconnection("Connectionstring")
oConn.open
' DataAdapter to get the information out of the database
Dim oDA as new DataAdapter("SELECT UserName, UserID FROM Users",oConn)
' Dataset used to store the data retrieved from the database
Dim oDS as new DataSet
' Fill the dataset with info from the database
oDA.Fill(oDS)
' Set your listbox datasource to the dataset
MyListBox1.DataSource = oDS
' Set the text values (The values that the will appear in the listbox)
MyListBox1.DataTextMember = "UserName"
' Set the vallue values (The values that are associated with the text items that appear in the listbox)
MyListBox1.DataValueMember = "UserID"
' Bind the listbox to the datasource
MyListBox1.DataBind()
Hope this helps you out. You could also populate the listbox much like you would have using classic ASP using the DataReader object. The DataReader can be thought of as a foward only recordset object like the one available in classic ADO
VB Code:
' open the connection
' Command object
Dim oCommand as new oledb.oledbCommand("SELECT UserName, UserID FROM Users",oConn)
Dim oDR as New DataReader
oDR = oCommand.ExecuteReader()
While oDR.Read
' Populate the datalist item much like you did in classic ASP
MyListBox1.Add(oDR("UserName"))
End While
I usually code in SQL server so the Access bizzo (oledb) might not be right
Cheers
MarkusJ