Click here to Skip to main content
15,923,083 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am redirecting the ids from main page to productcatalog.aspx page.. on productcatalog.aspx page.

On productcatalog.aspx page . i have written a query

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


Can i pas Request.querystring["id"].tostring as string or i should pas it in as numaric...

and in debugger i am getting the ids from the main page as..

C#
query	"Select * from Products where ProductID= ',63,64,65' AND UnitCost < 5000"	string


but data is not shown in grid.. what is the problem how to sort out that one.

is their something wrong in generated query..

on the main page i have made a logic as below..

C#
tring querydr = "select * from Products";
           SqlDataReader dr = obj.fillcomb(querydr);
            
            while (dr.Read())
            {
                 
                if(proid == String.Empty)
                  {
                 proid =  dr["ProductID"].ToString(); 
                 }
              else
                 {
                     proid += "," + dr["ProductID"].ToString();
                }
 
 
                }
            
          
 
       Response.Redirect("ProductCatalog.aspx?ID="+proid);
Posted
Updated 28-Dec-11 5:46am
v2

You can pass string in your query string. That is not the problem.
The problem is with the query itself.
 
Share this answer
 
Comments
Wendelius 28-Dec-11 13:25pm    
Exactly. Good clarification.
You cannot use equality for multiple values so instead of having
SQL
...where ProductID= ',63,64,65'...

you should write
SQL
...where ProductID IN (63,64,65)...

(Taken that the values are numerical in the database)
 
Share this answer
 
Comments
Abhinav S 28-Dec-11 13:03pm    
Correct. 5.
Wendelius 28-Dec-11 13:24pm    
Thanks Abhinav :)
Espen Harlinn 28-Dec-11 13:25pm    
Right - 5'ed!
Wendelius 28-Dec-11 13:30pm    
Thank you Espen :)

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