?
Solved

ADO - SQL Sever

Posted on 2001-08-01
5
Medium Priority
?
198 Views
Last Modified: 2013-11-23
Why do we need ADO locking if SQL Server uses its own locking system
0
Comment
Question by:Morphism
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 3

Expert Comment

by:nigelrowe
ID: 6339637
It is wise to leave locking to SQL Server, it automatically calculates the locking level which should be used. You can use ADO sql execution to force a particular type of lock, but you'd better be careful.
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6339745
ADO locking is there to provide you with feedback on the locking state in a multi-user system. If you use adLockOptimistic for every transaction then you may encounter problems updating a record that is locked by another user. adLockPessimistic raises an error if you attempt this and you can then deal with the failed update, retry or abandon it. SQL Server on its own will not do this for you unless you build it into the stored procedures that you call using ADO. In many ways this is a better option, that is using stored procedures and building in verification of updates/inserts and recovery. This would allow your application to run in the same manner using any data access technology.
0
 

Author Comment

by:Morphism
ID: 6348295
so I should really use stored procs instead of ADO executes or ADO Recorsets?
0
 
LVL 43

Accepted Solution

by:
TimCottee earned 200 total points
ID: 6348634
If you are designing an application in a multi-tier structure then the database layer should be independent of the data access layer, in a SQL server implementation this means effectively that you design it using stored procedures and call these procedures from your data access layer. This has many benefits; you stored procedures can be easily modified without having to make code changes, you can secure the tables/views so that users cannot make changes to the data without using the stored procedures - this provides a consistent data manipulation strategy, the execution plan for a compiled stored procedure is already determined by sql server and therefore doesn't need to be determined for each statement executed on the client, if you develop for multiple user interfaces/data access technologies again you are guaranteed a consistent data manipulation regardless of the front-end.

I am a big fan of using stored procedures in this way, whilst it can add a bit of time at the beginning it is a much more controllable and effective way of developing an application (IMHO).
0
 

Author Comment

by:Morphism
ID: 6358632
how do you mean the database layer should be independent
of the dataaccess layer
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question