久久久久久久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 的原因)
主站蜘蛛池模板: 亚洲福利视频网 | 成人精品一区二区户外勾搭野战 | 亚洲成在线观看 | 青青草综合网 | 成人性生交大片免费看r链接 | 欧美日本一区 | 日韩视频精品在线 | 日韩精品久久一区 | 高清视频一区二区三区 | 亚洲社区在线 | 日韩精品二区 | 人人人人干 | 欧洲一级黄 | 在线视频一区二区三区 | 人操人人 | 日日网| 亚洲人在线 | www.日韩| 日韩av免费在线电影 | 日韩一区二区在线观看视频 | 欧洲一区视频 | 亚洲国产看片 | 久久久久网站 | 欧美一级在线观看 | 日韩中文一区二区三区 | 欧美成人精品二区三区99精品 | 91成人免费看片 | 久久99蜜桃综合影院免费观看 | 免费观看的av毛片的网站 | 久久久五月天 | 精品国产乱码久久久久久丨区2区 | 久久精品国产久精国产 | 亚洲精品电影网在线观看 | 成人黄色在线 | 成人羞羞国产免费视频 | 日本福利在线观看 | 久久久九九九九 | 日韩伦理一区二区 | 亚洲精品视频在线看 | 妹子干综合| 精品久久久久国产 |