Click here to Skip to main content
15,880,392 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

Most likely you have missed parenthesis and the BETWEEN keyword. Try something like:
C#
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)";
 
Share this answer
 
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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900