问题描述
我开到本地MySQL服务器,并在 connection.Open()
方法方面,它抛出这个错误:
I'm opening a connection to a local MySQL server and on the connection.Open()
method it throws this error:
System.NotSupportedException:MySQL的连接器/网络目前还不支持分布式事务
在MySql.Data.MySqlClient.MySqlConnection.EnlistTransaction(交易>交易) 在MySql.Data.MySqlClient.MySqlConnection.Open()
我做的是这样的:
var connection = new MySql.Data.MySqlClient.MySqlConnection(ConfigurationManager.ConnectionStrings["Connection"].ConnectionString);
connection.Open();
在App.config的连接字符串是
The connection string in the app.config is
<add name="Connection" connectionString="server=localhost;user id=userid;Password=password;database=dbname" providerName="MySql.Data.MySqlClient" />
我不知道为什么它试图征用事务,我没有指定任何交易与放大器;我只有我连接一个MySQL服务器
I don't know why it's trying to enlist the transaction, I haven't specified any transactions & I only have one MySQL server I'm connecting to
推荐答案
尝试添加招募=假
来连接字符串:击>
编辑:从的MySQL Connector / .NET文档,如果您设置 AutoEnlist = FALSE
在连接字符串中它应该工作。
from the MySQL Connector/.NET documentation, if you set AutoEnlist=false
in the connection string it should work.
<add name="Connection" connectionString="server=localhost;user id=userid;Password=password;database=dbname;AutoEnlist=false" providerName="MySql.Data.MySqlClient" />
看来,ADO.NET的某些版本可以默认为自动争取一个连接到现有的事务。请参阅http://msdn.microsoft.com/en-us/library/ms254973.aspx对于更多的细节,但我希望以某种方式在某处ADO是迷茫的,以为有一个现有的事务正在进行一些其他的分贝。
It appears that certain versions of ADO.NET can default to automatically enlisting a connection into an existing transaction. See http://msdn.microsoft.com/en-us/library/ms254973.aspx for more detail, but I expect somehow somewhere ADO is confused into thinking that there's an existing transaction going on to some other db.
这篇关于为什么打开连接MySQL中抛出一个分布式事务错误? (.NET连接器)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!