C#中的并发控制 [英] Concurrency control in C#

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

问题描述

i have developed a website for registering to an exam which is published
flow goes like this
1. student register Application id generated Identity col
2. he fills the application form
3. saves
4. when he submits form his roll number is generated so i have written a stored procedure which updates student information and assigns him with a roll number





我的尝试:



现在的问题是两名学生同时获得同一个保存按钮的滚动编号。所以我怎么能避免这种情况。我不能应用唯一约束,因为该网站已发布,它将通过例外,我不能停止网站维护。目前我在数据库上手动触发查询以查找重复记录并使用缺少的卷号手动更新



What I have tried:

now problem is that often two students are getting same roll number who hit save button at same time . so how can i avoid this. i can not apply unique constraint because the site is published and it will through exception and i can not halt site for maintenance. currently i am manually firing query on data base for finding duplicate record and update it manually with the missing roll number

推荐答案

我猜你的SP会执行SELECT MAX来生成tol卷号?

如果您使用的是MSSQL Server 2012或更高版本,我建议您使用SEQUENCES:

tps://msdn.microsoft.com/en-us/library/ff878091.aspx [ ^ ]
I guess your SP does a SELECT MAX to generate tol roll number?
In case you are using MSSQL Server 2012 or later I ywould suggest you to use SEQUENCES:
tps://msdn.microsoft.com/en-us/library/ff878091.aspx[^]


这篇关于C#中的并发控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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