Click here to Skip to main content
14,425,522 members
Rate this:
Please Sign up or sign in to vote.
See more:
this query works fine for me..

tring query = "Select * from Products where ProductID in ('" + Request.QueryString["ID"].ToString().Substring(1) +"') AND UnitCost < 5000";


but when i amend it to add some more information. the query doesnot works well. whats the problem with fallowing query

tring query = "Select * from Products where ProductID in ('" + Request.QueryString["ID"].ToString().Substring(1) +"') AND UnitCost < 5000 or ProductID in ('" + Request.QueryString["ID"].ToString().Substring(1) +"') AND UnitCost  5000 and 10000 ";
Posted

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Most likely you have missed parenthesis and the BETWEEN keyword. Try something like:
string query = "Select * from Products where (ProductID in ('" + Request.QueryString["ID"].ToString().Substring(1) +"') AND UnitCost < 5000) or (ProductID in ('" + Request.QueryString["ID"].ToString().Substring(1) +"') AND UnitCost BETWEEN 5000 and 10000)";
   
Comments
Espen Harlinn 28-Dec-11 16:37pm
   
5'ed!
Wendelius 28-Dec-11 16:56pm
   
Thank you Espen :)
theanil 28-Dec-11 17:18pm
   
5+
Wendelius 28-Dec-11 17:33pm
   
Thank you theanil :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100