|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Sunday, April 17, 2005 12:40 PM
Points: 2,
Visits: 1
|
|
|
|
|
|
Say Hey Kid
      
Group: General Forum Members
Last Login: Thursday, December 13, 2012 1:38 AM
Points: 693,
Visits: 123
|
|
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
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Thursday, November 03, 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
|
|
|
|
|
Grasshopper
      
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
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Thursday, August 05, 2004 5:22 AM
Points: 1,
Visits: 1
|
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Tuesday, May 07, 2013 10:43 AM
Points: 287,
Visits: 213
|
|
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
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Wednesday, August 03, 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
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Thursday, April 25, 2013 8:57 PM
Points: 139,
Visits: 214
|
|
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
|
|
|
|
|
SSC 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?
|
|
|
|