我使用 vb.net 2008,我想将 txtEmpNo 绑定到 txtRate。但我检查了专栏是正确的。
错误“无法绑定到 DataSource 上的属性或列 Rate。参数名称:dataMember”
此代码:
Private Sub txtEmpNo_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtEmpNo.KeyPress
Dim da3 As New SqlDataAdapter
Dim ds3 As New DataSet()
Dim sqlRate As String = "SELECT Max(Rate) From EmployeeSalary WHERE EmployeeRun = '" & txtEmpNo.Text.ToString & "'"
da3 = New SqlDataAdapter(sqlRate, Conn)
da3.Fill(ds3, "EmployeeRun")
If ds3.Tables("EmployeeRun").Rows.Count > 0 Then
txtRate.DataBindings.Add(New Binding("Text", ds3.Tables("EmployeeRun"), "Rate"))
txtRate.DataBindings.Clear()
Else
txtRate.Text = ""
End If
End Sub
谢谢你的时间。:)