Link to home
Start Free TrialLog in
Avatar of HKFuey
HKFueyFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Web search on SQL database fails on backslash

We have a web site and if you search for a product code with 2 slashes e.g. 123/456/7 in it fails. The search seems to be controlled from a stored procedure (see below) can anyone help?


 
-- Search Products (name,Code)
insert into @SearchResults (ResultID,ResultName,ResultType,ResultLink,ResultDescription,ResultImage,ResultMixed,Sort,ResultDescription2)
select DISTINCT OurCompany_Product.ProductID, OurCompany_Product.[Name],'Products','Product.aspx?ProductID='+cast(OurCompany_Product.ProductID as varchar),
cast(OurCompany_Product.Description as varchar(5000)),OurCompany_Product.ImageUrl,Code,1,cast(OurCompany_Product.Summary as varchar(5000))
from OurCompany_Product
left outer join OurCompany_Product_ProductCategory on OurCompany_Product.ProductID=OurCompany_Product_ProductCategory.ProductID
INNER JOIN   OurCompany_ProductCategory ON OurCompany_Product_ProductCategory.ProductCategoryID = OurCompany_ProductCategory.ProductCategoryID
where (OurCompany_Product.[Name] like '%'+@SearchText +'%' or Code like '%'+@SearchText +'%') AND OurCompany_Product_ProductCategory.ProductCategoryID <> @GenAccessID AND OurCompany_Product.Live = 1
AND Code NOT IN (SELECT ResultMixed FROM @SearchResults) AND OurCompany_Product_ProductCategory.ProductCategoryID <> @SparePartID;

Open in new window

SOLUTION
Avatar of Brendt Hess
Brendt Hess
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi, do you get an error or just no results?

Regards
Avatar of HKFuey

ASKER

Hi Guys,
Just testing now but beginning to think bhess1 is right and the SP is OK and the issue is with the C Sharp code that is calling it.
HK
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of HKFuey

ASKER

Thanks