I am using SQL Server 2008 R2 Express with VS2010 ultimate c#. It's a client server architecture software of registering patients. there are 4 clients where 4 users are registering the patients. When 2 users are registering 2 separate patients and they hit the save button, then I am doing the following steps,
- system pulls the next registration no.
- saves the record with a that registration no. into SQL Server table
- again pulls the next registration no. for the next patient
If both users press the save button exactly at the same time, then SQL Server should put them in a queue regardless of the face that both users have hit the save button at the same time, SQL Server should execute the insert command of first patient, then generate next number and second insert command should execute just next to the first. so that the second query can pull the next registration no and then save the record. but it is saving two patient with the same registration no. I have even used BeginTransaction
, Commit
and Rollback
as well but still I am in a fix. Any help will be appreciated.