how to handle the database when multiusers are inserting data at same time


1.First user click on save button
2.sp_1 will be execute which is used to insert the data in table1
3.primary key value will be retrive from sp_1 to aspx.cs form.
4 sp_2 will be execute next. Which is used to inset the data in table2 with the primary key of table1

At the point 1 more than one user press Save button and only one user data is saving in database while others data is not saving.

Any solution for this.

6 Years
Discussion Span
Last Post by vishalrane

You need to use transactions. Transactions lock the records in use while one user is still altering them, blocking others until the resources are free again. You'll find plenty of examples online but basicallyyou begin a transaction, make your insertions, updates, deletes to the database and then either commit the changes or rollback if an error occurred.

Hope that helps,

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.