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

flow

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.

Recommended Answers

All 2 Replies

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,

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.