且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

"操作是无效的事务和QUOT的状态;错误和交易范围

更新时间:2023-02-17 13:37:53

之后做一些研究,看来我不能有两个连接打开到同一数据库与TransactionScope的块。我需要改变我的code看起来是这样的:

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            
            //do my call to the select statement sp
        }

        //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
    }
}