Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #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?


Reply With Quote
  #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
Reply With Quote
  #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?


Reply With Quote
  #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.
Reply With Quote
  #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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 07:13 PM.


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