AllExperts > Experts 
Search      

Active Server Pages Programming (ASP)

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More Active Server Pages Programming (ASP) Answers
Question Library

Ask a question about Active Server Pages Programming (ASP)
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Srini Nagarajan
Expertise
I can answer any kind of questions in ASP.NET, C#, VB.NET, SharePoint 2007, ASP, Coldfusion, Powerbuilder 7.00 / 8.00, JAVA servlets, MS SQL 2000 / MSSQL7, Sybase

Experience
Contact me if you need any custom development on ASP.NET, ASP, SharePoint 2007, Coldfusion, Powerbuilder.
 
   

You are here:  Experts > Computing/Technology > Business Software > Active Server Pages Programming (ASP) > Pessimistic Record Level Locking of SQL Table

Topic: Active Server Pages Programming (ASP)



Expert: Srini Nagarajan
Date: 3/26/2008
Subject: Pessimistic Record Level Locking of SQL Table

Question
I have ASP front end application and SQL Server 7.0 backend database. When a user updates a record on the ASP page, I want that record to be pessimistically record level locked so that no other person can edit or update the record. But other users can edit and update other records in this SQL table.  Can you direct me to some sample code that will carry out this operation?  Or tell me at what part of the ASP code I need to add new codes?  I have one ASP page where you enter the customer id number and then the request is sent to SQL Server where it returns the particular recordset and populates a 2nd ASP page.  When a user is editing this page, the record level lock will prevent other users from editing the same record.  Thank you.

Answer
Hi,

You need to do the following steps since you are using SQL server 7.0 and Classic ASP

1. First create a Application variable called "UpdateRecs"
2. When you retrieve the record for edit update the "UpdateRecs" something like this

      Application.Lock
      Application("UpdateRecs") = Application("UpdateRecs") & ", " & Customer_ID
      Application.Unlock

3. After retrieve record, check whether "UpdateRecs"  contains customerID if yes, display LOCK message else continue the edit

4. While you update the record remove the customerID from Application Variables.

this will be quick and easy.  Use application.lock and unlock on every instance.

Thanks

-Srini

Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.