Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keep others from updating a record while I'm updating it. 1

Status
Not open for further replies.

joasp

MIS
Sep 6, 2001
2
0
0
US
In detail. I'm using ASP and SQL Server

Let's say I'm in the process of modifying a customer's address info. in a form on my IE browser. I don't want anyone else to be able to bring up the same customer record. They should be notified that another user is in the process of updating it.

How to I accomplish this in an ASP environment even if my customer info. form consists of several ASP pages.

I must be missing somthing simple.
 
If I recall, SQL has it's own record locking.

However, what you could do, is have a field in each recored called "locked"

then whenever someone opens a record, in the same page write to that field, "locked"

also do a check onthat field.

 
SQL Serverhas locking but I dont know how to maintain that lock in a web environment. I would like to lock the record on the first ASP page where they enter the customer and keep it locked untill they fill out all 3 customer info web pages and then release it on the final submit on the last page.

Theres got to be a better way then a manual lock.

Thanks!!
 
I don't think that a manual lock can be improved upon using built in SQL stuff... because connections in ASP are "stateless" meaning that once a page loads, that's it... connection gone, locking is gone....

However, I also don't agree with the posted solution because there's always gonna be times when a user logs in, locks a record, and then decides not to finish what they are doing, and just surfs on over to some other page.... then that leaves you with a perpetually locked record.

I would suggest to use a variation of the solution presented but have some extra information in there like sessionID or something, where you could query the server to make sure that the particular session was/is still active...

if it is, then the record is locked, and you could choose your course of action (either a wait loop, or a message indicating the lock) -- and if it's not still active, then release the lock and let the user do what they need to do... wouldn't be terribly complicated.

The only other way to do this (that I can think of) would be to place a recordset with pessimistic locking into a session object -- that would keep its state and keep the lock on the record until you were done with it. The recordset would be destroyed if the user closed their browser.... BUT!!! and this is a big but... session level object seriously inhibit the performance of a server on high traffic sites, and so the question is:

"Is my site high traffic, could it ever be high traffic, or am I a low traffic site where this would not affect the performance of my application"

hope that helps! :)
Paul Prewett
penny.gif
penny.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top