I have a Select Statement Like this..
Select * From A Join B on A.ID = B.ID
And A.Gener = 'M'
And A.Age = 21
And B.School = 'Bluh'
--- many more AND Clauses
now these “AND” Clauses are dynamic, they will be build based upon user selection within my vb.net web application….
for example…
if gener.text <> "" Then
qry = qry & " And A.Gender='M'"
I dont really want to build my SQL query on the fly like this. is there a way of doing it better using LINQ or something else?
my actual SQL Query will contain up to 30 dynamic AND’s (Based upon user selection).
please advise.
Thanks
i would change it this way
— many more AND Clausesju
this way if you pass null values into procedure they would be logicly ignored – dont know if it works in your case
definetly building dynamic tsql query application side is a invitation for sql injection