I have been facing this problem for long time.
I have two BUTTONS on my form. btnNEXT,btnSUBMIT ..
when user clicks on btnNEXT,details of the next record are displayed. Then user enters some data and clicks on btnSUBMIT. This action will update the details of that particular record.
Now, I have around 10 users working on it. when user1 clicks on btnNEXT, he ll get a record to modify. Now i want that record to be locked and no other user can see that record. when User1 enters details and clicks on btnSUMBIT, the record ll be updated and lock will be released.
Another Scenario: User1 clicks on btnNEXT. then the record ll be locked. If the user closed the application without updating any data, the record should be unlocked.
What I have done: Begin tran Select top 1 * from table with (updlock,readpast) where condition
Update table set a=1,b=2 where id=123 commit tran
above queries satisfy my conditions for locking and unlocking the rows. But i want to Begin the transaction in btnNEXT_Click event and Commit transaction in btnSUMBIT_Click event
How can i achieve this?.. I am unable to think beyond this. Please advice me if you have any alternative that can satisfy my whole scenario
Thanks a lot