473,406 Members | 2,369 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,406 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 1238
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.