Problems with setting up an n-tier architecture

S

Scott

I thought I would stop hard-coding all my db commands and came up with (what
I thought is) an n-tier architecture to deal with data access. I have set
up a simple scenario to test:

I have an object named "SQLConnect.vb" which is supposed to be the generic
data layer and has a function in it called "RunSQLWithDataSet" and takes a
SQL string and a connection string. The idea is that a business object can
call it with the 2 pieces of information and return a dataset. This works
fine.

Taking it to the next level, I wanted to make a "RunStoredProc" Function to
call stored procedures. My thinking is that I would pass a 2D array to pass
the datatypes and values which would be passed to the stored procedure in
the function. In short: this is not working. Is there an example or
template for this sort of thing available? I can't believe I am the only
one to try this. Is there a better way? Is there ideas out there already
on how to architect this?

Scott
 
M

M K

Hmm... I don't know what code you are using, but off the top of my head,
your method would look something like this:
Public Sub RunStoredProc (inputCmdString, inputParamArray)
Dim SQLCmd As New SQLClient.Command(inputCmdString)
SQLCmd.CommandType = StoredProcedure
For Each _item In inputParamArray
SQLCmd.Parameters.Add(New
SQLClient.Parameter(_item("dataType"),_item("value")))
Next
End Sub

Something like that. What code are you actually using?
 
C

Colin Young

You are still hard-coding your DB commands using this sort of scheme. All
you are doing is duplicating the functionality of ADO.Net, and you aren't
even gaining independance from the underlying database because you still
have all the SQL commands in your business objects.

Check out www.llblgen.com for an example of how to write a good layer to
isolate your business objects from the DB implementation.

Colin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

2 Tier and N-Tier 10
Basic n-tier architecture question... 4
n-Tier development 23
N Tier Architecture ? 2
n tier applications 2
Architecture Question Business Layer 2
proper n-tier validation 1
3 Tier architecture 2

Top