Click to See Complete Forum and Search --> : problem with like query in stored procedure..


swapcode
May 17th, 2006, 12:59 AM
hi,
i m trying for a search criteria where user will enter anything in textbox and need to display the result in datagrid.

now problem is that i m using like query as

IF @ItemName <> ''
SET '(ITEMNAME LIKE ''' + @ItemName + '%'')'

but this is not filtering if user enters % in the text box and it displays all the values in the grid
Pls help me how to solve this issue.

WarlockSoul
May 17th, 2006, 07:56 AM
Hi swapcode,

I think that when the user entered the wild card character into the text box and then paasing it to the store procedure it change the procedure from using the like state as 'begin with' to 'contains' (%name%).

Have you tried removing the wild card character the user entered in the text box before passing to the stored procedure.

e.g.

textbox.text = Replace(textbox.text, "%", "")