473,320 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Problems with setting up an n-tier architecture

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
Jul 21 '05 #1
3 1235
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?

"Scott" <sc***********@nospam.ma-hc.com> wrote in message
news:u$**************@TK2MSFTNGP12.phx.gbl...
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

Jul 21 '05 #2
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

"Scott" <sc***********@nospam.ma-hc.com> wrote in message
news:u$**************@TK2MSFTNGP12.phx.gbl...
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

Jul 21 '05 #3
Scott,

Take a look at this link:
http://www.c-sharpcorner.com/Code/20...pActivator.asp

Also look at Microsoft's Data Access Application Block for .Net:
http://msdn.microsoft.com/library/de...ml/daab-rm.asp

Good Luck

"Scott" <sc***********@nospam.ma-hc.com> wrote in message
news:u$**************@TK2MSFTNGP12.phx.gbl...
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

Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Dave Anderson | last post by:
I have one IIS 6 machine that seems to ignore global.asa completely. I can't get *anything* to fire -- not Session_OnStart(), not typelib declarations. This is true in the web root as well as in...
1
by: manish | last post by:
Hi, I am a fresher in the programming field i.e although I have done programming at the basic level but at professional level I am very new and I am facing many problems. These probllems are...
2
by: josepe | last post by:
Hi, I have an asp site web with connections to a SQL server database. All works ok in a Server of USA, I have changed to a new server in UK and I have configured the new server as the USA...
1
by: Rolan | last post by:
Having tried various permutations of Before Update and well for that matter, After Update, OnExit, OnEnter, etc. and also Locked controls, I'm still unable to obtain the intended results. There are...
13
by: tshad | last post by:
How do we handle Caching in IE? It seems that my system works fine in Mozilla and Netscape when I make changes. But in IE the changes are not brought across when someone has been to the site...
3
by: Newbie | last post by:
Hi All Trying to create a mini-ASP web dev with a couple of PCs at school. When the teachers are happy with the site on the LAN then going to upload it to the school site. Problem is having...
9
by: =?Utf-8?B?SG93YXJkIFNtaXRo?= | last post by:
I am using VC++ 6.0 (with SP5 installed). When using WinXP this is with SP2 installed. I am developing an instrumentation system comprising a set of networked PCs connected using TCP/IP TCP links....
15
by: =?Utf-8?B?TWFkcyBOaWVsc2Vu?= | last post by:
Hi, I am developing a web service for a customer. The service has a method, that returns an array of Forms. Each form has a Name property of Type String. The customer wants the contract to...
5
by: Nefrit | last post by:
Ok, I can't figure it out, please someone else help if you know what to do. I have a Linksys Wireless G Router and Wireless G USB network adapter. My host computer is using Windows XP and there is no...
11
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I have worked with application settings in VS2005 and C# for awhile, but usually with standard types. I have been trying to store a custom container/class/type in an application setting and I have...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.