如何避免主键冲突? [英] How to avoid Primary Key violation?

查看:116
本文介绍了如何避免主键冲突?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
在在线订票系统中,例如火车票订票,当用户单击以获取新票时,他会注意到一个座位是免费的.但是,在单击订票按钮时,会收到一条消息,说明该座位已被预订,如果该座位已由他之前的某个人预订. ....

如何制作这个……?

当我工作时,出现错误消息主键"冲突(例如)
预先谢谢您.

Hi there
In online booking systems for instance train ticket booking the when user click for new ticket he notice a seat is free.But at the time of clicking booking button get a message that the seat is reserved,if it s reserved by some1 prior to him.....

How to make this....?

When I work I get error message "Primary Key" violation (Eg)
Thank You in advance

推荐答案

您可以在预订时锁定"该座位5分钟.
You could ''Lock out'' that seat for, say, 5 minutes, whilst booking.


这里有一些想法,以进一步推动DD的回答

您是否考虑过在尝试捕获区域中处理此类错误?或sql通知(假设您正在使用sql server 2005或更高版本!)
couple of thoughts here to further DD''s answer

have you thought of dealing with such error in the try catch area? or sql notification (asusming your using sql server 2005 or greater!)


这篇关于如何避免主键冲突?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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