>The idea is only when updating..
>edit button clicked...
>BEGIN TRANSACTION
>Call the function to lock...(Via SELECT for update ect..)
>Make update statement....and update record..
>END (COMMIT) TRANSACTION
If you only want a lock applied when you update the row, SQL Server will do this naturally. Unless you override the basic behavior, SQL Server will place an exclusive lock on the row or page before making the change. The exclusive lock will be held until the end of the transaction.
BEGIN TRANSACTION
UPDATE table SET column = value WHERE ... -- SQL will acquire exclusive locks
-- Exclusive locks are still being held
COMMIT TRANSACTION -- Exclusive locks will be released.
You can see this for yourself using either the SQL Profiler or sp_lock (maybe sp_locks).
-Mike