473,405 Members | 2,272 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,405 software developers and data experts.

With respect to the data access layer, what do you all do?

Do you all create dedicated data access layers for each project or do you
create resuable ones that you can use over many projects. Also, in the data
access layer, do you all create specific functions with the sql statements
hardcode into each and every function or just make a generic function and
pass it different sql statments? Thanks...
Nov 18 '05 #1
4 1299
well i write a set of classes to deal with specific data.
i.e. if you have users then there's a class like usersDB which just methods
to add/ update... validate...
if you have products then you have methods that deal in product related
info.
shopping cart would have methods relating to different things you can
perform on shopping cart with relation to db

no i do not hard code sql statements. But i try to make generic stored procs
for each table within the db
so product would have
product_add
product_update
product_select
product_select_all
product_select_active

i call the corresponding stored proc based on requirements. if its more than
one product and i need to show it in a tabular format
i return a disconnected dataset
if its just one product then i use SqlParameter to channel the data around.
For add / update i always end up using stored procs in conjugation with
SqlCommand and SqlParameters

I use stored procs cause its already compiled and has an execution plan at
hand.
SqlParameters so that i don't have to worry bout SQL hacks.. plus it takes
care of quotes " ' " for string based data types.

hope this helps...
--
Regards,
HD
Once a Geek.... Always a Geek
"Showjumper" <sh*******@grkjashdjkf.com> wrote in message
news:uj**************@TK2MSFTNGP09.phx.gbl...
Do you all create dedicated data access layers for each project or do you
create resuable ones that you can use over many projects. Also, in the
data
access layer, do you all create specific functions with the sql statements
hardcode into each and every function or just make a generic function and
pass it different sql statments? Thanks...

Nov 18 '05 #2
Thanks, that gives me some ideas.
"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:ut**************@tk2msftngp13.phx.gbl...
well i write a set of classes to deal with specific data.
i.e. if you have users then there's a class like usersDB which just methods to add/ update... validate...
if you have products then you have methods that deal in product related
info.
shopping cart would have methods relating to different things you can
perform on shopping cart with relation to db

no i do not hard code sql statements. But i try to make generic stored procs for each table within the db
so product would have
product_add
product_update
product_select
product_select_all
product_select_active

i call the corresponding stored proc based on requirements. if its more than one product and i need to show it in a tabular format
i return a disconnected dataset
if its just one product then i use SqlParameter to channel the data around. For add / update i always end up using stored procs in conjugation with
SqlCommand and SqlParameters

I use stored procs cause its already compiled and has an execution plan at
hand.
SqlParameters so that i don't have to worry bout SQL hacks.. plus it takes
care of quotes " ' " for string based data types.

hope this helps...
--
Regards,
HD
Once a Geek.... Always a Geek
"Showjumper" <sh*******@grkjashdjkf.com> wrote in message
news:uj**************@TK2MSFTNGP09.phx.gbl...
Do you all create dedicated data access layers for each project or do you create resuable ones that you can use over many projects. Also, in the
data
access layer, do you all create specific functions with the sql statements hardcode into each and every function or just make a generic function and pass it different sql statments? Thanks...


Nov 18 '05 #3
Showjumper wrote:
Do you all create dedicated data access layers for each project or do you
create resuable ones that you can use over many projects. Also, in the data
access layer, do you all create specific functions with the sql statements
hardcode into each and every function or just make a generic function and
pass it different sql statments? Thanks...


I normally create a 2-level data access layer. The first layer is the
lowest level data access. It has usually a worker class that has
methods like SelectSQLData(sql), ExecSproc(...), etc. and perhaps a
factory class if I need to support multiple databases (it would know how
to work with more than one provider). This is something all apps would use.

Then I create another layer of classes on top of those, which are
specific to the application I'm working on. These classes take inputs
and save/retrieve data from the database using the classes above.

This way I have one layer that is app-agnostic and reusable, and another
that is built on top of this original layer for each app.

BTW, I normally try to use stored procedures where possible, although
sometimes you can't and so my first layer supports SQL queries as well.

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Nov 18 '05 #4
thanks Craig. Thats given me another idea to work with
"Craig Deelsnyder" <cdeelsny@NO_SPAM_4_MEyahoo.com> wrote in message
news:u6*************@TK2MSFTNGP11.phx.gbl...
Showjumper wrote:
Do you all create dedicated data access layers for each project or do you create resuable ones that you can use over many projects. Also, in the data access layer, do you all create specific functions with the sql statements hardcode into each and every function or just make a generic function and pass it different sql statments? Thanks...
I normally create a 2-level data access layer. The first layer is the
lowest level data access. It has usually a worker class that has
methods like SelectSQLData(sql), ExecSproc(...), etc. and perhaps a
factory class if I need to support multiple databases (it would know how
to work with more than one provider). This is something all apps would

use.
Then I create another layer of classes on top of those, which are
specific to the application I'm working on. These classes take inputs
and save/retrieve data from the database using the classes above.

This way I have one layer that is app-agnostic and reusable, and another
that is built on top of this original layer for each app.

BTW, I normally try to use stored procedures where possible, although
sometimes you can't and so my first layer supports SQL queries as well.

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET

Nov 18 '05 #5

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

Similar topics

3
by: dror | last post by:
Hello, I have a problem that actually doesn't even make sense. I have 4 million rows in my database. I want to get all records into a DataReader and then read. So if I do it in DAO (either in VB...
0
by: sedefo | last post by:
I ran into this Microsoft Patterns & Practices Enterprise Library while i was researching how i can write a database independent data access layer. In my company we already use Data Access...
2
by: headware | last post by:
I'm relatively new to ASP.NET and ADO.NET, but I have a basic design question regarding the use of web services and APS.NET applications. Right now we have an application that uses web services to...
5
by: Andrea Williams | last post by:
I'm working with C# and I'm setting up some ENUM's I have a data and Business layer. I'm declaring a common enum for the Data Layer. The UI layer references the Bus layer and the bus layer...
3
by: Marc Castrechini | last post by:
First off this is a great reference for passing data between the Data Access and Business Layers:...
2
by: Ily | last post by:
Hi all I am using Visual studio 2005. Im my project I have a presentation layer, a business layer and a data access layer. From my business layer i have a reference to my data layer. I also...
3
by: kbutterly | last post by:
Good morning, I have seen two different types of data access layers and I am wondering which, if either, is considered best practice, or if one is better suited to certain situations than the...
3
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
I'm confused about Data Access Layer and Data Object Layer. How are they related? Which layer will be affected when the underlying database structure is changed? Which layer will be affect when...
3
by: Peri | last post by:
I have 3 layers. First - UI Layer (Windows Application - Thick Client) Second - Biz Layer (DLL) Third - Messaging Layer (DLL) The Messaging Layer is referenced in Biz Layer and Biz Layer is...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.