久久久久久久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 的原因)
主站蜘蛛池模板: 6080亚洲精品一区二区 | 亚洲一区二区中文字幕 | 91久久北条麻妃一区二区三区 | av天空| 日韩欧美久久精品 | 精品自拍视频在线观看 | 日韩一区二区在线视频 | 欧美一级在线观看 | 成人一区二区三区 | 久久99这里只有精品 | 免费黄色录像片 | 久久新视频 | 成人三级av| 久久精品国产亚洲夜色av网站 | 欧美激情99 | 91久久综合 | 丁香五月网久久综合 | 免费观看羞羞视频网站 | 狠狠天天 | 免费黄篇 | 亚洲在线免费 | 久久综合九九 | 一本大道久久a久久精二百 欧洲一区二区三区 | 久久久久久精 | 成人精品鲁一区一区二区 | 黄视频国产| 欧美中文字幕一区二区三区亚洲 | www.一级毛片 | 国产一区二区在线91 | 91久久国产综合久久 | 国内久久精品 | 中国三级黄色录像 | 一级黄a视频 | 91最新视频 | 国产精品一区二区三区在线 | 超碰伊人久久 | 狠狠涩| 亚洲综合字幕 | 欧美一级久久 | 亚洲欧美网站 | 国产精品亚洲一区二区三区在线 |