Sql server row lock

I developed a C # application where the form displays several employee details in a listview control. When a user clicks on a line, another form will open and show this employee record in more detail.

I want it to work so that the user sees a form where employee records were shown in more detail, that this record will be blocked in such a way that another user will not be able to see this record until the original user closes the details form. Please tell how I can create this type of application with SQL Server lock.

0
source share
2 answers

The preferred way would be ...

timestamp .

, , , .

...

userEditing , (, ). , "", , .

( Joe , , ), .

+2

:

BEGIN TRANSACTION
UPDATE someTable set SomeThing = 'new value' where someID = 1
-- this will lock 'someTable' in affected row as long as transaction alive.

-- in another connection
select * from someTable with (readpast)
-- this will skip locked rows

, .

  • , .
  • , , , / .
  • .
  • - - .
  • someTable with (readpast) .

"" . ASP.NET :

Application[string.Format("{0}.{1}", tableName, primaryKey)] = true;
0

Source: https://habr.com/ru/post/1784032/


All Articles