久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

“該操作對于交易狀態無效"錯誤和事務范圍

quot;The operation is not valid for the state of the transactionquot; error and transaction scope(“該操作對于交易狀態無效錯誤和事務范圍)
本文介紹了“該操作對于交易狀態無效"錯誤和事務范圍的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

當我嘗試調用包含 SELECT 語句的存儲過程時出現以下錯誤:

I am getting the following error when I try to call a stored procedure that contains a SELECT Statement:

該操作對交易狀態無效

這是我的通話結構:

public void MyAddUpdateMethod()
{

    using (TransactionScope Scope = new TransactionScope(TransactionScopeOption.RequiresNew))
    {
        using(SQLServer Sql = new SQLServer(this.m_connstring))
        {
            //do my first add update statement

            //do my call to the select statement sp
            bool DoesRecordExist = this.SelectStatementCall(id)
        }
    }
}

public bool SelectStatementCall(System.Guid id)
{
    using(SQLServer Sql = new SQLServer(this.m_connstring)) //breaks on this line
    {
        //create parameters
        //
    }
}

我在事務中創建到同一個數據庫的另一個連接有問題嗎?

Is the problem with me creating another connection to the same database within the transaction?

推薦答案

經過一些研究,我似乎無法使用 TransactionScope 塊打開到同一個數據庫的兩個連接.我需要修改我的代碼看起來像這樣:

After doing some research, it seems I cannot have two connections opened to the same database with the TransactionScope block. I needed to modify my code to look like this:

public void MyAddUpdateMethod()
{
    using (TransactionScope Scope = new TransactionScope(TransactionScopeOption.RequiresNew))
    {
        using(SQLServer Sql = new SQLServer(this.m_connstring))
        {
            //do my first add update statement            
        }

        //removed the method call from the first sql server using statement
        bool DoesRecordExist = this.SelectStatementCall(id)
    }
}

public bool SelectStatementCall(System.Guid id)
{
    using(SQLServer Sql = new SQLServer(this.m_connstring))
    {
        //create parameters
    }
}

這篇關于“該操作對于交易狀態無效"錯誤和事務范圍的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

LINQ to SQL and Concurrency Issues(LINQ to SQL 和并發問題)
SQL Server 2005 Transaction Level and Stored Procedures(SQL Server 2005 事務級和存儲過程)
Yield return from a try/catch block(try/catch 塊的收益回報)
Should I call Parameters.Clear when reusing a SqlCommand with a transation?(重用帶有事務的 SqlCommand 時,我應該調用 Parameters.Clear 嗎?)
Does SqlTransaction need to have Dispose called?(SqlTransaction 是否需要調用 Dispose?)
Reason for System.Transactions.TransactionInDoubtException(System.Transactions.TransactionInDoubtException 的原因)
主站蜘蛛池模板: 久久av.com| 黄色av网站在线观看 | 国产精久久久久久久妇剪断 | 久久免费资源 | 日韩a视频 | av免费网站在线观看 | 超碰日韩 | 久久精品成人 | 午夜欧美 | 观看av | 欧美日韩一区在线 | 国产第一页在线观看 | 中文字幕第100页 | 中文字幕乱码一区二区三区 | 黄色欧美视频 | 视频一区二区中文字幕 | 国产精品久久久久久影视 | 成人av免费播放 | 欧美精品一区二区三区四区 在线 | 免费在线日韩 | 久久综合九色综合欧美狠狠 | 日韩精品一区二区三区免费观看 | 狠狠涩| 99热精品久久 | 免费视频99 | 羞羞视频在线观看网站 | 亚洲444kkkk在线观看最新 | 91毛片在线观看 | 国产精品久久影院 | 成人免费视屏 | 欧美精品在线一区 | 伊人网站在线观看 | 黄色大全免费看 | 亚洲精品视频免费 | 在线视频 欧美日韩 | 91久久精品一区二区二区 | 免费精品 | 国产精品久久av | 成人一区av偷拍 | 中文字幕第一页在线 | 国产精品久久久久久久免费观看 |