jalo Posted October 22, 2005 Posted October 22, 2005 how can i change this command so that i can use LIKE, instead of " = " in the query (the part in red) ? 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 Quote
bri189a Posted October 22, 2005 Posted October 22, 2005 WHERE First_Name LIKE '%?%' AND Last_Name LIKE '%?%' should work... Some db's wild card is * instead of %. Quote
jalo Posted October 23, 2005 Author Posted October 23, 2005 this didn't work either :( after some playing with the syntax i finally got it to work like this: where First_Name LIKE '%'&?&'%' and Last_Name LIKE '%'&?&'%' i am using Access db and vb.net Quote
SonicBoomAu Posted October 23, 2005 Posted October 23, 2005 i would use where First_Name Like " & % & " and Last_Name LIKE " & % & " Access uses % as the wildcard figure Quote Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -- Rick Cook, The Wizardry Compiled
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.