Hello,
I'm having error when I try to filter my data (name)
In my Personal table, I have a column for name for ex: Mary Elizabeth Roger
When I type the name in searchbox, it appears as syntax error.
Here's my code
Private Sub SearchPD_Record()
Dim da As New OleDbDataAdapter
Dim dt As New DataTable
'try catch block is used to catch the error
Try
connection.Open()
command.Connection = connection
command.CommandText = "SELECT * FROM Personal"
command.ExecuteNonQuery()
If Me.combosearch.Text = "Name" Then
command.CommandText = command.CommandText & " where name like '%" & Me.txtsearch.Text
Else
command.CommandText = command.CommandText & " where idno =" & Me.txtsearch.Text
End If
da.SelectCommand = command
da.Fill(dt)
Me.dgrid.DataSource = dt
If dt.Rows.Count = 0 Then
MsgBox("No record found!")
End If
Catch ex As Exception
MsgBox(ErrorToString)
Finally
connection.Close()
End Try
End Sub