473,946 Members | 15,032 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1319
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*******@grkj ashdjkf.com> wrote in message
news:uj******** ******@TK2MSFTN GP09.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******** ******@tk2msftn gp13.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*******@grkj ashdjkf.com> wrote in message
news:uj******** ******@TK2MSFTN GP09.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(s ql), 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_SP AM_4_MEyahoo.co m> wrote in message
news:u6******** *****@TK2MSFTNG P11.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(s ql), 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
4869
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 or MFC C++) it takes around 1 second to get the recordset and then around 10-15 seconds to iterate through the recordset. This speed remains the same even if I incorporate an ORDER BY clause: SELECT * FROM myTable ORDER BY customer_id,...
0
5433
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 Application Block (DAAB) in our .Net projects. We use SqlHelper in SQL based projects, and OracleHelper in Oracle based ones. OracleHelper was not published officially by Microsoft as part of the DAAB but it was given as a helper code in a sample .Net...
2
2223
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 access the database layer. However, the code works in a pretty cumbersome and ungeneric way. Basically every query, update, and insert has its own function. So you see a lot of functions like webService.InsertCustomer(name, age, phone); or...
5
2682
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 references the Data layer, but I would like to have the enum exposed to all three. Is there a way to trickle down that enum (Like class inheritance exposes classes) so that it can be accessed from the Business layer and UI layers? My UI layer doesn't...
3
2695
by: Marc Castrechini | last post by:
First off this is a great reference for passing data between the Data Access and Business Layers: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/html/Anch_EntDevAppArchPatPrac.asp I use my own classes in the Business layer. I want to keep the Data Access layer from requiring these classes so I tried passing a Datarow between the layers and it seems to work good for me. Constructing the datarow in the Class...
2
1942
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 have a refeence to my business layer from my presentation layer. Now the weird thing is, I can create a form, and I can add a using
3
1305
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 other. The first type is the DAL described in this MSDN article as well as in the tutorial on the www.asp.net website: http://msdn2.microsoft.com/en-us/library/ aa581778.aspx#aspnet_tutorial01_dataaccesslayer_vb_topic3
3
3383
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 additonal information (more columns and/or from more tables) from the database is needed?
3
1520
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 reference in UI Layer. I have one class called "MessageValueEnum" in the Messaging layer which
0
9975
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11552
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10679
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8240
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7403
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6097
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6318
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4928
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3525
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.