cmcrae Posted April 2, 2003 Posted April 2, 2003 I am trying to populate a listbox with the information from a column that is inside a table in my microsoft Access 2000 database. Also I was wondering how to delete a record from that same database.. Quote
turrican Posted April 3, 2003 Posted April 3, 2003 If you are new to this like me, you may find it easier to populate the listbox at design time. I find it easier to bind the listbox to a dataset. I used the datasource property of the listbox. Im pretty sure that there are better ways, but this works for me. Quote
a_jam_sandwich Posted April 3, 2003 Posted April 3, 2003 This is an example of a dataset binding to a listbox Dim MyConn As New New OleDbConnection(<<CONNECTION STRING>>) MyConn.Open Dim MyAdapter As New OleDb.OleDbDataAdapter("SELECT * FROM TABLE", MyConn) Dim MyDataset As New DataSet() ' Create dataset MyAdapter.Fill(MyDataset, "TABLE") ' Fill dataset from adapter Listbox1.DataSource = MyDataset.Tables("TABLE") ' Set the datasource of listbox Listbox1.DisplayMember = "FIELDNAME" ' Set the field of the display column Listbox1.ValueMember = "ID" ' Set the field of the ID field (Optional) ' Cleanup code MyDataset.Dispose LendersAD.Dispose Thats for databinding Make sure you substitue your own connection string SQL and Fieldnames Andy Quote Code today gone tomorrow!
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.