Click here to Skip to main content
15,896,915 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi EveryOne

can you help me on this question
on how Converting custom controls search filters to dynamic SQL query with logical operators (AND OR)

Example Custom controls Click Here
Posted
Updated 20-Feb-12 11:01am
v2

1 solution

This is a very usual problem.

It would be the best to create a fixed set of "universal" fixed query strings using parametrized query approach.
Depending on the current status of the query control, you should select one of the queries from the set and perform substitution of the parameters.

Please see:
http://en.wikipedia.org/wiki/Parameterized_query[^],
http://msdn.microsoft.com/en-us/library/yy6y35y8.aspx[^].

For a code sample, take a look at this tutorial:
http://www.csharp-station.com/Tutorials/AdoDotNet/Lesson06.aspx[^].

Using a dynamic query string using on string manipulation like concatenation or based on StringBuilder is not efficient and considered unsafe due to the possibility of SQL injection. Please see:
http://en.wikipedia.org/wiki/SQL_injection[^].

—SA
 
Share this answer
 
Comments
zyck 20-Feb-12 21:58pm    
thanks for the reference
Sergey Alexandrovich Kryukov 20-Feb-12 22:20pm    
You are very welcome.
Won't you consider accepting the answer formally (green button)?
--SA
zyck 22-Feb-12 8:49am    
Im searching for more best solution by the way thanks again

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