Solved

ADO - SQL Sever

Posted on 2001-08-01
5
192 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 50 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

691 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