Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 locking records and multiple updates

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2000-11-07 : 13:09:00
Jason writes "Hi there,

Here's the scenario..

MSSQL 7.0
NT 4.0 SP6a
One ASP page calling and updating Record1 from Table1.
Two users performing this same operation at the same time.

User1 opens the RS and info sent to User1 Browser.
User2 opens the RS at the same time before User1 updates info.
User2 makes changes to fields 1,2 and 3 and updates RS.
User1 makes changes to fields 4,5 and 6 and updates RS.

However the page updates all fields when submitted.(ok maybe bad page design...)

The result... User1 just has just overwritten User2's updated data in fields 1,2 and 3 with the retrieved data from when they opened the page. Data inconsistency.

What I want to know is if you can lock the RS when the update page is loaded by User1's browser and not release the RS until User1 has updated their info. ie. Can I stop User2 from accessing (an I mean even viewing) the RS that User1 is updating at the time of the update?

An alternative that I came up with, was to dynamically build the SQL update statement based on the fields being updated, and leaving the other fields in the RS alone, but this is quite involved and requires considrable ASP script.

Is there a simple way to stop a second user accessing the RS while the first user is updating? And I don't just mean locking the RS during the actual moment of the update. I mean from when User1 opens the asp page, to when he closes the page.

Thanks,

Jason"
   

- Advertisement -