A
aaapaul
Best practice Multiuser Program - locking
I have to develop an application with Visual Studio .NET 2005 and SQL
Server 2005 (ADO.NET).
There is a sql-server table called "Orders" with primary key ordernr.
If a user calls "Edit Order Nr XY" in the program the datarow xy should
be locked.
When the user pushes the button "store", the datarow xy should be
updated and unlocked.
Due to the locking every outer user who wants to "Edit Order Nr XY"
should get the message "not possible".
How can this solved ?
My idea is this:
Two new fileds in the table (locked: boolean; lockedby: varchar)
1) READ for editing
SQL
UPDATE orders SET locked = true where (ordernr = 'xy') and (locked =
'false')
IF the return value = 1 then read datarow else "not possible, locked by
xy"
2) UPDATE
Update fileds and locked = false
Who has experience in solving such problems?
Many thanks for your help in advance.
Best regards
aaapaul
I have to develop an application with Visual Studio .NET 2005 and SQL
Server 2005 (ADO.NET).
There is a sql-server table called "Orders" with primary key ordernr.
If a user calls "Edit Order Nr XY" in the program the datarow xy should
be locked.
When the user pushes the button "store", the datarow xy should be
updated and unlocked.
Due to the locking every outer user who wants to "Edit Order Nr XY"
should get the message "not possible".
How can this solved ?
My idea is this:
Two new fileds in the table (locked: boolean; lockedby: varchar)
1) READ for editing
SQL
UPDATE orders SET locked = true where (ordernr = 'xy') and (locked =
'false')
IF the return value = 1 then read datarow else "not possible, locked by
xy"
2) UPDATE
Update fileds and locked = false
Who has experience in solving such problems?
Many thanks for your help in advance.
Best regards
aaapaul