Dim strSql As String = ""
strSql = "select * from Employees"
With cn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConn
.Open()
End With
With cm
.CommandText = strSql
.Connection = cn
dr = .ExecuteReader
End With
If dr.HasRows Then
dt.Load(dr)
With CbbEmployee
.DisplayMember = "EmployeeName"
.ValueMember = "EmployeeID"
.DataSource = dt
.Text = "<เลือกพนักงาน>"
End With
End If
cn.Close()
Dim strSql As String = ""
strSql = "select * from Employees"
With cn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConn
.Open()
End With
RemoveHandler CbbEmployee.SelectedValueChanged, AddressOf CbbEmployee_SelectedValueChanged
If dr.HasRows Then
dt.Load(dr)
With CbbEmployee
.DisplayMember = "EmployeeName"
.ValueMember = "EmployeeID"
.DataSource = dt
.Text = "<เลือกพนักงาน>"
End With
End If
cn.Close()
AddHandler CbbEmployee.SelectedValueChanged, AddressOf CbbEmployee_SelectedValueChanged
CbbEmployee.ContextMenu = New ContextMenu()
ไม่ได้บอกอีกทีนะ