I'm using the following code to populate a combo box from an access database:
I want to fill in some text boxes with the selection of the combobox. The database has 3 columns. The comboBox is populated by the first column and I want to fill the textboxs with column 2 and 3. I have tried databindings but I keep getting error messages when running the program. I tried:
I have tried several things in the second argument but nothing seams to work.
1. Can I use this code inside a while statement to bind the textbox?
2. Do I need to declare a new datatable and data adapter for each while statement?
Thanks in advance.
Code:
Dim cm As New OleDbCommand("select * from employee", m_cn)
Dim dr As OleDbDataReader = cm.ExecuteReader
While dr.Read
cboEmployeeName.Items.Add(dr(0).ToString)
End While
Dim cm1 As New OleDbCommand("select * from workcenter", m_cn)
Dim dt1 As New DataTable
Dim dr1 As OleDbDataReader = cm1.ExecuteReader
While dr1.Read
cboworkcenter.Items.Add(dr1(0).ToString)
End While
dr.Close()
dr1.Close()
Code:
txtemployeeID.databinding.add("text", , "Value Stream")
1. Can I use this code inside a while statement to bind the textbox?
2. Do I need to declare a new datatable and data adapter for each while statement?
Thanks in advance.