Link to home
Start Free TrialLog in
Avatar of angelarmando
angelarmando

asked on

Multi Criteria Filter in Windows Form

Hi Folks,

Here again just trying to point to the right direction. I have a Windows Form App created in Visual Basic.NET 2008 very simple composed of a few forms and reports. I want to make my filters to my data in SQL a little more dynamic. I can create a simple filter instance using the wizards in Visual Studio and creating custom queries but now I want to use multiple criteria. What is the best approach for this? A new form that you can use to select and filter data from? How do I do that? Any light is appreciated.

Thanks,

Armando
Avatar of blandyuk
blandyuk
Flag of United Kingdom of Great Britain and Northern Ireland image

Can't you just simply use an SQL Stored Procedure and pass parameters into it, then bind the results? This way you can filter / order the results however you wish.
ASKER CERTIFIED SOLUTION
Avatar of blandyuk
blandyuk
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of angelarmando
angelarmando

ASKER

Hi blandyuk,

Both solutions sounds feasable. I have no problems hitting the DB again. Which is better to learn. Creating SP in SQL or the New list approach? Any links that you can share?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi jp,

Right. That is a great idea. Now in my case the SQL side is very restricted (the DBAs are very territorial.....lol) and to maintain those might be a problem. How about the second choice? the new list (of object)? Any link to that approach?

Thanks guys for the leads BTW,

Armando
Depends how you have coded your project, I'm assuming you have created your Objects and other layers:

Object Layer
Data Layer
Business Layer

I have a "FilterEngine.vb" class in my Busines Layer which deals with object filtering. Example below:
Public Shared Function PersonFilterByTitle(ByRef listP As List(Of Person), ByVal title As String) As List(Of Person)
	Dim newList As New List(Of Person)

	For Each item As Person In listP
		If item.Title = title Then
			newList.Add(item)
		End If
	Next item

	Return newList
End Function

Open in new window

I don't work that way and I always do using the SP.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you guys... I will look into that.


Armando