我知道有很多帖子有这个问题,但我似乎无法在我的代码中找到错误,有什么想法吗?
继承我的代码:
Private Sub btnSearch_Click(sender As Object, e As EventArgs) Handles btnSearch.Click
On Error GoTo SearchErr
If txtSearch.Text = "" Then
Exit Sub
Else
Dim cantFind As String = txtSearch.Text
MainBindingSource.Filter = "(Convert(ID, 'System.String') LIKE '" & txtSearch.Text & "')" & _
"OR (Student ID LIKE '" & txtSearch.Text & "') OR (First Name LIKE '" & txtSearch.Text & "')" & _
"OR (Last Name LIKE '" & txtSearch.Text & "')"
If MainBindingSource.Count <> 0 Then
With dgvStudentInfo
.DataSource = MainBindingSource
End With
我试图在Vb.net中搜索Access数据库
答案 0 :(得分:0)
我认为SQL正在看到&#34;学生ID&#34;作为两个字。如果您的表字段中确实有空格,则需要添加括号,&#34; [学生ID]&#34;。 (您可能需要单引号或双引号标识符而不是括号。不确定。)