Passing filtering rules into a query

I am writing a report/query that pulls back a certain amount of records and then further filters them using rules that they can build. I was going to store the rules in an sql table and then use them when they call the query.  How can I pass those rules into the query?  an example of a rule is flag false when product was used in the last 120 days.  Thanks in advance.
mwhodgesAsked:
Who is Participating?
 
CodeCruiserCommented:
Loop through the array like

Dim str As string = "Select * From ... Where " 
For each rule As String in Rules
   str &= Rule & " AND"
Next
str = str.Trim.Trim("AND").Trim
0
 
CodeCruiserCommented:
You have to do some appending and string manipulation.
0
 
mwhodgesAuthor Commented:
Can I load the rules into an array and then how can I pass them?
0
 
mwhodgesAuthor Commented:
Thanks exactly what I needed.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.