what is the syntax for a LIKE query

jalo

Active member
Joined
Aug 9, 2005
Messages
28
how can i change this command so that i can use LIKE, instead of " = " in the query (the part in red) ?

Code:
Private Sub doCommand()
     
         command = New OleDb.OleDbCommand("Select Patient_ID, SS_Patient_ID, First_Name, Middle_Name, Last_Name, Date_of_Birth from Demographics [COLOR=Red]where First_Name = ? and Last_Name = ?[/COLOR]", Me.OleDbConnection2)
        command.Parameters.Add(New OleDb.OleDbParameter("Fname", OleDb.OleDbType.VarChar, 20))
        command.Parameters.Add(New OleDb.OleDbParameter("Lname", OleDb.OleDbType.VarChar, 20))

        command.Prepare()

        command.Parameters.Item("Fname").Value() = Me.TextBox1.Text
        command.Parameters.Item("Lname").Value() = Me.TextBox2.Text
    End Sub
 
WHERE First_Name LIKE %?% AND Last_Name LIKE %?%

should work...

Some dbs wild card is * instead of %.
 
this didnt work either :( after some playing with the syntax i finally got it to work like this:

Code:
where First_Name LIKE %&?&% and Last_Name LIKE %&?&%

i am using Access db and vb.net
 
Back
Top