Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
can we send multiple value with query string if yes how ?
Posted
Comments
Rahul Rajat Singh 9-Mar-12 4:31am    
are talking about sql query or url querystrings ?

C#
string query = string.Format("select * from {0} where {1}='{2}'", "tblMyTable", "myColumn", 0);


Is that what you meant?
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 8-Mar-12 13:15pm    
Good, this is probably the minimal sample (not counting impractical "select * from my_table").
For the next step, parametrized query should be recommended.
My 5.
--SA
#realJSOP 8-Mar-12 13:47pm    
Impractical is in the eye of the beholder. The minimal sample matches the minimal question. :)
Sergey Alexandrovich Kryukov 8-Mar-12 19:50pm    
I'm not sure you got my comment. In other words, you sample was not absolutely minimal, but minimal among the practical ones.

Cheers,
--SA
Are you talking about passing multiple parameters in a query string? If you are, all you need to do is append them to the query string using the format
HTML
&key=value
Okay, that seems straightforward enough, but is it enough? Well no - the important thing to understand is that the query string is part of the URL, so this means that you need to encode your values (and not use invalid keys). .NET provides the handy HttpUtility.UrlEncode which you should use on the values to ensure that they are suitable for passing across - don't forget to decode them at the receiving end with HttpUtility.UrlDecode.

The question is, should you really use query strings? A query string represents a point of attack against your system. By this I mean that it is another area that "hackers" can use to target your website looking for vulnerabilities, and loopholes to exploit. There are several famous query string attacks*, so you really need to think long and hard about whether this is the appropriate mechanism for you, or whether you would be better using alternate mechanisms such as session values to operate your site. I can't answer this for you - only you know your requirements so you are best placed to judge whether or not it's appropriate.

*a couple of the vulnerabilities include: buffer overflow attacks, code injection.
 
Share this answer
 
www.testwebsite.com?one=1&two=2&three=3&four=4

assuming you are talking about URL query strings.
 
Share this answer
 

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