Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

ADO.NET - A Data Access Layer Expand / Collapse
Author
Message
Posted Friday, July 16, 2004 11:31 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Sunday, April 17, 2005 12:40 PM
Points: 2, Visits: 1
Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/PNowa
Post #126717
Posted Tuesday, August 3, 2004 4:04 AM
Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Friday, September 6, 2013 2:16 AM
Points: 693, Visits: 124

Patrick,

You wrote "we have to ensure that the SQL command passed to the procedure is actually a SELECT statement". I hope that you realize that the statement could be something like this:

SELECT 1 DELETE _t_spsys_select_log WHERE log_id=(SELECT MAX(log_id) FROM _t_spsys_select_log)

This means that we must trust the developer of the client application to give us a correct SELECT statement. This means that we trust that he only uses hard-coded strings or if he uses anything entered by the user, he validates them very well. If anyone wants to read further on this topic, see:

http://www.nextgenss.com/papers/advanced_sql_injection.pdf

Razvan




Post #129814
Posted Tuesday, August 3, 2004 5:38 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, November 3, 2011 2:30 AM
Points: 31, Visits: 19

Razvan raises a good point, and one that reinforces the suggestion that a data layer is a good idea.  It's much easier to prevent SQL Injection and the like in a dedicated data layer, than on every individual SQL call.

Tony

Post #129830
Posted Tuesday, August 3, 2004 7:04 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, October 19, 2007 6:32 AM
Points: 23, Visits: 20

A few issues I see with this approach. I'm curious as to your opinion on them:

1) It does nothing to prevent SQL injection attacks. I can pass in something like "select * from table ; delete * from table", which would qualify as a select statement, but would execute both the select and the delete statement. Very dangerous and hard to catch.

2) Aren't you losing all the benefits of running stored procs by using sp_executesql? None of the queries are running against pre-compiled sprocs that way, and some queries can be very long and complex (much more than 1000 characters).

Again, I really like the idea of a data access layer (it's been on our development list for a while now). I'm just not sure what the best approach is for it. I prefer to require the client to access all data through stored procedures (we develop a web based app), which makes it hard to develop a generic interface.

Just my $0.02. I'm curious to hear what other people think.

Greg Walker
DBA
ExpenseWatch.com




Greg Walker
DBA, ExpenseWatch.com
Post #129844
Posted Tuesday, August 3, 2004 7:25 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, August 5, 2004 5:22 AM
Points: 1, Visits: 1

havent read the whole article, just wanted to let you know about the "Data Access Application Block" published by microsoft for that exact purpose, it is quite easy to use, details and downloads can be found here :

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/daab-rm.asp

 

cheers

rugha




-------------------------
Oh no, I've done it again...
-------------------------
Post #129854
Posted Tuesday, August 3, 2004 7:58 AM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Today @ 7:38 AM
Points: 295, Visits: 278

The Data Access Application Block is really quite excellent. This is also another opportunity to plug Code Generation. I know, I know, I promised to write an article on the topic and I started one but it sucked I'll get back to work on it soon.

My point is, you should not have to write 80% of the stored procedures or any of the data access layer. Let a code generator do the generic stuff for you. Check out CodeSmith at http://www.ericjsmith.net/codesmith/ or the Code Generation Network at http://www.codegeneration.net/.



Bryant E. Byrd, BSSE MCDBA MCAD
Business Intelligence Administrator
MSBI Administration Blog
Post #129866
Posted Tuesday, August 3, 2004 8:00 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, August 3, 2005 2:06 AM
Points: 2, Visits: 1

Hi all,

My DAL starts with Stored Procedures and prepared commands and we use .NET framework components with corresponding typed datasets. Then you can drop your DAL Component and needed datasets to Win/WebForm and call its methods. It is good idea to create typed dataset properties in your component so it will allow you to select dataset instance using IDE property editor - cheers!

Common DAL "framework" should be comprised of component base classes. That's how I see this problem. Btw, when you use SqlCommand object's parameters collection, "sql injection" is not a problem any more.

Have a nice day




Post #129869
Posted Wednesday, August 4, 2004 10:11 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, May 8, 2014 6:02 AM
Points: 146, Visits: 238
I agree with all Patryks reasons for using a data access layer.

I also re-iterate rugha's comment - see the microsoft SqlHelper class which they publish separately as a freely downloadable Data Access Application Block.

This allows the coder to use static methods to perform most data access tasks which makes things much easier. You can of course build on this to do logging etc...

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/daab-rm.asp
Post #130249
Posted Wednesday, August 3, 2005 7:06 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, January 28, 2013 11:40 AM
Points: 45, Visits: 79

Does DAL refuse Data-Binding approach? In other words can it be used when one wants a GUI control (as opposed to developer's SQL code) to take care about SELECT / UPDATE / INSERT / DELETE?

I am having problems with an old application relying heavily on data binding. It needs to migrate to .NET. The database gradually became pretty ugly during its many-years lifetime.

I'd love to create / use a DAL approach which seems to be the only way to maintain the application's being up and running while "remodeling" is being in progress. But...

What about the first question in this post please?

Post #206836
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse