I have a function that gets called with a parameter called "name" now it works fine.. until i do a search with a ' in it.. so I am sending this as the name
Plastic & Foam 3'X5' XLT
When i send that it returns empty in the website (no errors) but if i send jusr Plastic & Foam
it works fine, it comes back ok. Now in the sql part I get this when i send the query through management studio like this
exec sp_productSearch 'Plastic & Foam 3''X5'' XLT'
SELECT Name FROM PProducts WHERE NAME LIKE '%Plastic & Foam 3'X5' XLT'
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'X5'.
In C# i am sending the text list this
Server.HtmlEncode(txtproductname.Text.Trim().Replace("'", "''"))
Any Ideas what I may be doing wrong?
PS: The stored procedure is simple, is something like this
Select Name from PProducts Where NAME LIKE '%' + @NAME + '%' ;
Thank you.