多用户同时插入数据时如何处理数据库 [英] how to handle the database when multiusers are inserting data at same time
本文介绍了多用户同时插入数据时如何处理数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
流程
1.第一个用户单击保存按钮
2.sp_1将被执行,用于将数据插入到table1
3.主键值将从sp_1检索为aspx.cs形式.
接下来将执行4个sp_2.用于通过table1的主键插入table2中的数据
在第1点,有多个用户按保存按钮,只有一个用户数据正在保存在数据库中,而其他数据则没有保存.
任何解决方案.
Indrish
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.
Indrish
推荐答案
您需要了解交易.例如,从这里开始:
http://sqlserverpedia.com/wiki/Transaction_Overview [ http://msdn.microsoft.com/en-us/library/aa255996%28v = sql.85%29.aspx [ ^ ].
尝试找到更多信息: http://en.lmgtfy.com/?q=SQL+transaction+管理+概述 [ ^ ].
—SA
You need to learn about transactions. For example, start from here:
http://sqlserverpedia.com/wiki/Transaction_Overview[^],
http://msdn.microsoft.com/en-us/library/aa255996%28v=sql.85%29.aspx[^].
Try to find some more: http://en.lmgtfy.com/?q=SQL+transaction+management+overview[^].
—SA
这篇关于多用户同时插入数据时如何处理数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文