Before i go on i am aware this is more of a sql problem then vb but its stumped me. I am using a access database, i have the drivers and all that it works fine thats not the issue im trying to search the database using partial text i can easily get it to pull out data if i spell something perfect but thats not great people make mistakes. here is my code
i search from any page, it sends me here and pulls the partial search text out of the url "search=", then using sql querys i search for terms like it i was told to add "%" as its a wildcard meaning i can do partial text but it stil dont work it just comes up with the error "Syntax error (missing operator) in query expression 'LIKE%searchtext%'. "
im not sure what operator im missing didnt think i needed one
Code:
Imports System.Data.OleDb
Partial Class _Default
Inherits System.Web.UI.Page
Dim cs As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Server.MapPath("Beds.accdb")
Dim cn As New OleDbConnection(cs)
Dim cmd As OleDbCommand
Dim r As OleDbDataReader
Dim sql As String
Dim G As String
Dim s As String
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
sql = "SELECT * FROM Patient WHERE LIKE" & "%" & Request.QueryString("search") & "%"
cmd = New OleDbCommand(sql, cn)
cn.Open()
r = cmd.ExecuteReader()
s = "<br />"
Do While r.Read()
s = r("Surname") & ", " & r("Forename") & "<br />"
Loop
cn.Close()
results.innerhtml = s
End Sub
End Class
im not sure what operator im missing didnt think i needed one