处理并发用户问题. [英] Handling Concurrent user issue.

查看:68
本文介绍了处理并发用户问题.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在SQL2008上使用asp.net时遇到一个并发用户问题,如果两个用户启动该应用程序并单击保存",则它允许将记录保存两次.我需要避免保存重复的记录.我该如何做到呢?

我想到的一件事是在启动时获取Modifiedat值,并将此值与数据库记录进行比较(如果该值不同),那么我将向第二个用户显示消息.现在的问题是,我们迁移了具有与Modifyat相同的数据的记录.

任何人都可以让我们知道处理并发问题的最佳方法.
非常感谢您的帮助.
-Mani

Hi,

I am using asp.net with SQL2008 facing a concurrent user issue, if two users launches the application and clicks save then it is allowing to save the record twice. I need to avoid saving duplicate record. How can I acheive this?

One thing I thought of taking Modifiedat value at the time of launching and comparing this value with database record if it differs then I will display message to the second user. Now the problem is we have migrated records which has same data of modifiedat.

Can any one let us know the best way to handle concurrency issue.
Your help is much appreciated.
-Mani

推荐答案

您可以考虑两件事:

0)您可以在有人请求数据时锁定正在修改的记录,然后在记录被锁定时第二个用户请求它时,将编辑字段设置为只读.在表单上放置一个刷新按钮,并允许用户重新请求数据,直到他自己可以锁定它为止.

1)当用户检索数据时,保存数据的副本,允许用户更改它,当他保存数据时,将两个版本的数据都传递给数据库.如果他的原始数据副本与数据库中的当前副本不同,请提示他采取进一步的措施.


Two things you can consider:

0) You could lock the record being modified when someone requests the data, and then when a 2nd user requests it while the record is locked, make the edit fields read-only. Put a refresh button on the form and allow the user to re-request the data until he can put a lock on it himself.

1) When the user retrieves the data, save a copy of the data, allow the user to change it, and when he saves it, pass BOTH versions of the data to the database. If his copy of the original data is different than when is currently in the database, prompt him for further action.



ASP.NET和SQL Server中的并发用户更新 [ ^ ]


这篇关于处理并发用户问题.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆