简体   繁体   English

插入记录时锁定

[英]Lock at the time of Inserting record

I have windows service have two method which are inserting data to the same table at the same time.but at the time of insert it threw the exception.how i can make lock on such situation. 我有Windows服务有两种方法,它们同时将数据插入到同一张表中。但是在插入时,它引发了异常。如何锁定这种情况。

thank you in advance 先感谢您

if its update statement, i would suggest BEGIN TRANSACTION with READ COMMIITED isolation level. 如果它的更新语句,我建议使用READ COMMIITED隔离级别进行BEGIN TRANSACTION。 but since its insert, u might want to create extra table act like a queue. 但是自从插入以来,您可能想要创建额外的表,就像队列一样。 Insert everything in new table and after that u can run your validation. 将所有内容插入新表,然后您可以运行验证。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM