Record Filtering/Selecting Data Access Layer

Cavar

Well-known member
Joined
Sep 5, 2006
Messages
60
Programming Experience
5-10
So, I've been reading up on creating a n-tier application and understand some of the basics such as selecting, saving and deleting data via custom business objects.

All of the samples I have found so far select data using something similar to the following in the Business Logic Layer:

VB.NET:
Public Shared Function SelectAll() As List<Product>
	SQLDataAccessLayer dal = SQLNew DataAccessLayer
 
	Return dal.ProductSelectAll()
End Function

I've also seen various methods for selecting by an ID.

How do you select Products using an unknown number of parameters? On my web page I might have the following fields to help filter data on screen:

Sold To: <person name>
Sold Between: <fromdate> - <todate>

Would I have to create a method with 3 parameters or would I have my Presentation Layer build a search string and pass that to my DAL via the BLL? What happens if I add another set of paramters on screen such as:

Order Status: <dropdown>

There seem to be plenty of samples on the web for simple data selection, but not complex data selection. Or maybe I'm just not understanding something, probably the latter.

Any thoughts would be appreciated.

CT
 
Read DW2 for how to get the IDE to make the DAL for you

For variant parameters you must form the SQL so as to understand wildcards:

VB.NET:
SELECT * FROM
table
WHERE
(col1 = :parameter1 or :parameter1 IS NULL) AND
(col2 = :parameter2 or :parameter2 IS NULL)

Now, for all records, make both param null, for all matching col1, set col1 and leave parameter2 null..
 
Last edited by a moderator:
Back
Top