Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 19th, 2003, 01:34 AM
Authorized User
 
Join Date: Aug 2003
Location: , , .
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default locking of records

I want to lock the record (e.g. invoice)
when the browser load the page and unlock the
record when the browser left the page.

Can ASP handle this case?
If the client machine halt, how can we release the lock?


  #2 (permalink)  
Old August 19th, 2003, 03:54 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

I would advise against actually applying a database lock to the record. Better to add some new fields, e.g. LockDateTime and LockUser, and fill these when the browser loads the page and clear them when the browser leaves the page.

You can then handle the client halting by looking at the new fields the next time a user wants to see the same invoice. For example:
- if another user requests a locked invoice, compare the current Date/Time to the LockDateTime field and if its more than, say, 20 mins ago (you need to decide a reasonable interval for your users) allow the new user to view it and update the LockDateTime and LockUser with new values
- if the same user request the invoice again, let them view it and update the LockDateTime.

You can also schedule a database job to clear out the values in LockDateTime and LockUser at suitable intervals (again you need to decide what is reasonable for your application).

hth
Phil
  #3 (permalink)  
Old August 19th, 2003, 04:19 AM
Authorized User
 
Join Date: Aug 2003
Location: , , .
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

How can i clear the lock when the browser leave the page?
Is there any method to clear the lock when the user
click the "X" of the IE to close the window?


  #4 (permalink)  
Old August 19th, 2003, 04:24 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

You can use javascript function trigerred by onunload event of <body> to send data to an ASP page to clear the lock.
  #5 (permalink)  
Old August 19th, 2003, 04:40 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Copenhagen N, , Denmark.
Posts: 217
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mega
Default

I guess you could do something like this:

<body onunload=exit(<%= Request.Session)>
<script language="JavaScript" type="text/javascript">
  function exit(sessionID){
    document.write('<img src="releaseLock.asp?ID='+sessionID+'" width="1" height="1" alt="">');
  }
</script>

Regards - Jon


Similar Threads
Thread Thread Starter Forum Replies Last Post
Form Locking dancook Access VBA 2 November 7th, 2006 11:38 AM
Database Locking royalsurej General .NET 2 November 9th, 2004 08:24 AM
Locking a record Bune SQL Server 2000 3 August 26th, 2003 09:50 AM
Locking Peter Riley SQL Server ASP 3 June 5th, 2003 07:24 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.