2008,我希望将txtEmpNo绑定到txtFullName。但我查了一下这是正确的。
错误“无法绑定到DataSource上的属性或列[名字]。参数名称:dataMember”
此代码:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim da3 As New SqlDataAdapter
Dim ds3 As New DataSet()
Dim bs2 As New BindingSource()
Dim sql As String = "SELECT Employee.[First Name] From Employee WHERE Employee.EmployeeNo = '" & txtEmpNo.Text.ToString & "'"
da3 = New SqlDataAdapter(sql, Conn)
da3.Fill(ds3, "Employee")
If ds3.Tables("Employee").Rows.Count > 0 Then
txtFullName.DataBindings.Add(New Binding("Text", ds3, "Employee.[First Name]"))
txtFullName.DataBindings.Clear()
Else
txtFullName.Text = ""
End If
End Sub
感谢您的时间。
答案 0 :(得分:0)
dataMember
参数(第3个)应该只是列的名称
应该在第二个参数中传递DataSet中的正确表。换句话说,将绑定更改为:
txtFullName.DataBindings.Add(New Binding("Text", ds3.Tables("Employee"), "First Name"))