使用LINQ从SQL SERVER重新生成数据时出现死锁问题 [英] Getting deadlock issue while reteriving a data from SQL SERVER using LINQ

查看:232
本文介绍了使用LINQ从SQL SERVER重新生成数据时出现死锁问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误:事务(进程ID 52)在锁定时死锁与另一个进程通信缓冲资源并被选为死锁牺牲品。重新运行交易。



请帮助。

Error : Transaction (Process ID 52) was deadlocked on lock | communication buffer resources with another process and has been chosen as the deadlock victim. Rerun the transaction.

Please help.

推荐答案

我认为以下链接将帮助您理解和实现双重拍摄机制。



http://msdn.microsoft.com/en-us/library/aa937573%28v=sql.80%29.aspx [ ^ ]



http://social.msdn.microsoft .com /论坛/ en / sqldatabaseengine / thread / e0210b4f-61c4-41f3-a573-c5fe7ac33b5e [ ^ ]
I think following links will help you to understand and implement the touble shooting mechanism.

http://msdn.microsoft.com/en-us/library/aa937573%28v=sql.80%29.aspx[^]

http://social.msdn.microsoft.com/Forums/en/sqldatabaseengine/thread/e0210b4f-61c4-41f3-a573-c5fe7ac33b5e[^]


查看此博客

http://stackoverflow.com/questions/190666/linq-to-sql-and-concurrency-issues [ ^ ]

--NDK
check this blog
http://stackoverflow.com/questions/190666/linq-to-sql-and-concurrency-issues[^]
--NDK


您可以通过代码使用goto语句再次重试来解决这种情况,因为死锁在访问数据库的非常特定的时间内发生了



You can solve this case through code by using goto statement to retry again because dead lock happened in a very specific time while accessing database

public int update_anything()
    {
    try_again:
      //your stuff here ...

      thisConnection.Open();

      try
      {

        myCommand.ExecuteNonQuery();

       }
    catch (SqlException exception)
    {
        MessageBox.Show(exception.Message);

        // to handle the sql server dead lock issue when two process
        // access  the same row
        if (exception.Number == 1205)
        {
            goto try_again; ;
        }
        else
        {
            throw;
        }
    }
    finally
    {
        thisConnection.Close();
    }
}


这篇关于使用LINQ从SQL SERVER重新生成数据时出现死锁问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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