I am Using Parameters with the ObjectDataSource Control (ASP.net, VB code behind)
I am trying to use
ObjectDataSource_RECORDID_GV1.SelectParameters.Add(“City”, “X”)
at run time
Does this work with “like” so that anytime a parameter is empty all the records are returned
such as (where City like ‘%’)
I have multiple controls that will setup my where conditions.
what is the best practice to setup the SQL query in my XSD.
because I may have condtions such as:
where state = X and city = y and price > 1000
OR
Where State = X and Price > 2000
OR
City = y
How would I build this SQL Query in which all the Where parameters may change on the fly?
This isn’t the most efficient SQL query ever, but the easiest SQL query would require you set the parameter value to NULL in code when you don’t want to filter by it and then use:
... WHERE (@state IS NULL OR @state = state) AND (@city IS NULL OR @city = city) AND (@price IS NULL OR @price = price) ...(This assumes you use parameters named
@state,@city, and@price.)