• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 672
  • Last Modified:

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.
0
mwhodges
Asked:
mwhodges
  • 2
  • 2
1 Solution
 
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
 
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
 
mwhodgesAuthor Commented:
Thanks exactly what I needed.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now