OLEDB提供程序错误新的事务无法加入指定的事务协调器 [英] Error with OLEDB provider New transaction cannot enlist in the specified transaction coordinator

查看:116
本文介绍了OLEDB提供程序错误新的事务无法加入指定的事务协调器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

        }
     }

代码可以与sqlclient提供程序一起正常工作,但如果使用oledb提供程序,则会出现错误新事务无法加入指定的事务协调器。
已在服务器上启用DTC服务。

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.

推荐答案

您不能在一个事务中打开多个连接,因此创建连接对象并在事务作用域外打开它,然后将其存储在会话中,以便在会话中重用它,然后在事务处理后完全确保关闭连接以避免任何问题。

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.

这篇关于OLEDB提供程序错误新的事务无法加入指定的事务协调器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆