Error with OLEDB provider New transaction cannot e

2019-07-27 15:04发布

    using (TransactionScope transactionscope = new TransactionScope())
    {
     try
        {
            function1(); //perform update on table
            function2(); //perform update on table 
            transactionscope.Complete();
        }
        catch(Exception ex)
        {

        }
     }

Code working fine with sqlclient provider but in case of oledb provider it gives error "New transaction cannot enlist in the specified transaction coordinator". Already enable DTC service on server.

enter image description here

1条回答
虎瘦雄心在
2楼-- · 2019-07-27 15:24

You can not open connection in transaction more than one, so create connection object and open it outside of the transaction scope store it in session reuse it where you want within transaction, after transaction complete insure to close connection to avoid any issue.

查看更多
登录 后发表回答