I had been used to using the convention of the older VB 6.0 database connections and code. I have been told to start using the new conventions , so I have anew project I'm starting and I need some help.
In the code below I have loaded data into to combo boxes. but you will see how I changed the naming for the variables in the second box. I appears I am not empting or finalizing something when I leave the names the same on the second box I get the data but also a LOT of empty spots(best way to describe). Any help on this code would be appreciated.
Thanks
In the code below I have loaded data into to combo boxes. but you will see how I changed the naming for the variables in the second box. I appears I am not empting or finalizing something when I leave the names the same on the second box I get the data but also a LOT of empty spots(best way to describe). Any help on this code would be appreciated.
Thanks
Code:
Private Sub frmWorkOrder_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
frmWorkOrderListing.Close()
HoldScreenError = False
'Work Requested By Combo Box
Dim cn As New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=..\Hy-Tech Maint2.mdb")
Dim da As New OleDbDataAdapter()
Dim dt As New DataTable()
cn.Open()
da.SelectCommand = New OleDbCommand("select tblemployees2.EmployeeName From tblEmployees2 Order by tblemployees2.employeeName", cn)
da.Fill(dt)
cboWorkReqBy.DataSource = dt
cboWorkReqBy.DisplayMember = "Employees"
cboWorkReqBy.ValueMember = "EmployeeName"
cboWorkReqBy.Text = "(Select the Employee)"
cn.Close()
' Machine Number ComboBox
Dim da2 As New OleDbDataAdapter()
Dim dt2 As New DataTable()
cn.Open()
da2.SelectCommand = New OleDbCommand("select tblmachine.machinenumber From tblmachine Order by tblmachine.MachineNumber", cn)
da2.Fill(dt2)
cboMachineNumber.DataSource = dt2
cboMachineNumber.DisplayMember = "Machine"
cboMachineNumber.ValueMember = "MachineNumber"
cboMachineNumber.Text = "(Select the Machine #)"
cn.Close()
End Sub