我创建了一个组合框,并在加载表单时填充它,并且每当我在组合框中选择一名员工时,它就会运行良好。但是,每当我选择姓氏为“ BAUTISTA”的员工时,我都会得到错误的employeeid。当我查看调试器时,我选择的员工的employeeid为100009,但id的实际值为10008。
ds = sqlfunction.getTable("SELECT * FROM TABLE")
With cmb_employee
.DataSource = ds.Tables(0)
.ValueMember = "employeeid"
.DisplayMember = "sname"
End With
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button3.Click
Dim employee As String
employee = cmb_employee.SelectedValue.ToString.Trim
LoadLoans2( employee)
End Sub
Private Sub LoadLoans2(ByVal type As String, ByVal employee As String, ByVal status As String)
Dim ds As DataSet
DataGridView1.DataSource = Nothing
ds = sqlFunctions.getTable("select * FROM TABLE WHERE employeeid=employeeid AND loanid="THE VALUE THAT I SELECT")
With DataGridView1
.AutoGenerateColumns = True
.DataSource = ds.Tables(0)
End With
ds.Dispose()
End Sub
在线ds = sqlFunctions.getTable("select * FROM TABLE WHERE employeeid=employeeid AND loanid="THE VALUE THAT I SELECT")
变化employeeid=employeeid
至employeeid="& employee &"
另一个问题:您的代码提供了Private Sub LoadLoans2(ByVal type As String, ByVal employee As String, ByVal status As String)
但看起来您仅用1个参数调用了另一个子:LoadLoans2( employee)