November 18th, 2012, 06:36 PM
Using LIKE '%variable%' with a parameterized query
I am trying to accomplish something like...
SELECT ItemID, ItemNumber, ItemDesc FROM ITEMS WHERE ItemDesc LIKE '%variable%'
The problem is I am using a parameterized query, so it is structure like...
rsItems_cmd.CommandText = "SELECT ItemID, ItemNumber, ItemDesc FROM ITEMS WHERE ItemDesc LIKE ?"
and then passing the parameter...
rsItems_cmd.Parameters.Append rsItems_cmd.CreateParameter("param1", 200, 1, 50, rsItems__Variable
(Where rsItems__Variable is a string of the value passed)
How do I use a LIKE command when passing a text string as a parameter??
November 21st, 2012, 09:55 PM
'set the variable with initial value
rsItems__Variable= source of whereever it is coming from
'append the %'s to it before feeding it to the query
rsItems__Variable= "%" & rsItems__Variable & "%"
Brinkster- free development account. Not affiliated, but I sure like free. Brinkster.com