4

I'm opening a connection to a local MySQL server and on the connection.Open() method it throws this error:

System.NotSupportedException: MySQL Connector/Net does not currently support distributed transactions.
at MySql.Data.MySqlClient.MySqlConnection.EnlistTransaction(Transaction> transaction) at MySql.Data.MySqlClient.MySqlConnection.Open()

All I'm doing is this:

var connection = new MySql.Data.MySqlClient.MySqlConnection(ConfigurationManager.ConnectionStrings["Connection"].ConnectionString);
connection.Open();

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

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

Glenn Slaven
  • 33,720
  • 26
  • 113
  • 165
  • What does `ConfigurationManager.ConnectionStrings["Connection"].ConnectionString` look like? (Please sanitize any IP addresses or passwords before posting) – Femi Sep 01 '11 at 03:19
  • I've updated above with the connectionstring – Glenn Slaven Sep 01 '11 at 03:21

1 Answers1

10

Try adding Enlist=false to your connection string:

EDIT: 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" />    

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.

Femi
  • 64,273
  • 8
  • 118
  • 148
  • System.ArgumentException: Keyword not supported. Parameter name: enlist at MySql.Data.MySqlClient.MySqlConnectionStringBuilder.ValidateKeyword... – Glenn Slaven Sep 01 '11 at 03:43
  • Ha, close! It's 'Auto Enlist'. I cracked open Reflector & dug around in the MySql.Data code. Update your answer & I'll mark it as accepted, thanks! – Glenn Slaven Sep 01 '11 at 03:55