这就是我所拥有的无法绑定错误
Dim STSQL = <sql>SELECT Employee_id, First_name, MIDDLE_INITIAL, last_name,
(Employee_id || ' ' || First_name || ' ' || last_name) As EmpName
FROM mpcs.Employee</sql>.Value
rsMPCS = MPCS_SELECT_SQL(UCase(STSQL), rsMPCS)
dtEmp = New DataTable
dtEmp.Load(rsMPCS)
cboEmployee.DataSource = dtEmp
cboEmployee.DisplayMember = "EmpName"
cboEmployee.ValueMember = "ID"
答案 0 :(得分:0)
首先改变这个
Public ArrEmployee(3, 0) As String
到
Dim x as Integer = number of employees( if you don't know put it larger than expected)
Public ArrEmployee(x, 3) As String
然后这部分应该是这样的
ArrEmployee(x, 0) = rsMPCS("Employee_id")
ArrEmployee(x, 1) = rsMPCS("First_name")
ArrEmployee(x, 2) = rsMPCS("MIDDLE_INITIAL")
ArrEmployee(x, 3) = rsMPCS("last_name")
x += 1
最后当你想添加到组合框
时For x = 0 To UBound(ArrEmployee, 2) - 1
Dim textToAdd As String = String.Format("{0} {1} {2} {3}", ArrEmployee(x, 0), ArrEmployee(x, 1), ArrEmployee(x, 2), ArrEmployee(x, 3))
cboEmployee.Items.Add(textToAdd)
Next
说,你应该真正制作员工类,然后列出那个类。从长远来看,整洁,做得恰到好处。