Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a gridview in which all the meetings are displayed with time slot.On clicking cell in gridview it redirect to update page on which user can update time slot.i want that if one user updating one cell then than cell can not be updated by other user.....how can i add such constrain on cell....
Posted
Updated 24-Nov-15 0:23am
v2

1 solution

Add your updation code in transaction that automatically lock table while updating.
SQL
CREATE PROCEDURE [ProcedureName]
AS
BEGIN
  BEGIN TRANSACTION
  -- lock table "TableName" till end of transaction
  SELECT [ColumnNames]
  FROM [TableName]
  WITH (TABLOCK , HOLDLOCK)
  WHERE ...

  -- do some other stuff including insert/update table "TableName" 


  -- release lock
  COMMIT TRANSACTION
END 

TABLOCK will prevent updates by other sessions,You can use TABLOCKX that prevent both updates and reads
 
Share this answer
 
Comments
Member 12141812 24-Nov-15 6:41am    
but i want that other slot can be updated by user

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900