Error with OLEDB provider New transaction cannot enlist in the specified transaction coordinator

我怕爱的太早我们不能终老 提交于 2019-12-11 05:18:16

问题


    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.


回答1:


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.



来源:https://stackoverflow.com/questions/39410682/error-with-oledb-provider-new-transaction-cannot-enlist-in-the-specified-transac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!