title: Disable AutoCommit using C# Mysql Connector after an unhandled exception
body: <p>I'm currently developing a C# application with MySql as backend database.</p>
  
  <p>Unfortunately I found a wired behaviour I can't explain.</p>
  
  <p>I wanted to use transactions, to "combine" multiple queries to make sure only all commands or none are executed.</p>
  
  <p>However, because of a coding error by me, an unhandled exception occured during the transaction.</p>
  
  <p>My understanding of a transaction is, that in such a case, the transaction is rolled back.</p>
  
  <p>Nevertheless I found out that Mysql seems to enable AutoCommit by default and commits after the disconnect because of the crash resulting from the unhandled exception.</p>
  
  <p>So I tried to disable it by executing <code>SET autocommit = 0</code></p>
  
  <p>But this doesn't work.</p>
  
  <p><strong>EDIT:</strong>
  I created the transaction using following code:</p>
  
  <pre><code>_transaction = _mysqlConnection.BeginTransaction();
  MySqlCommand cmd = new MySqlCommand();
  cmd.Connection = _mysqlConnection;
  cmd.Transaction = _transaction
  </code></pre>
  
  <p>Other people mentioned, that the usage of BEGIN should solve this issue, but this isn't the case. In the Mysql log the following querys are executed:</p>
  
  <pre><code>239 Connect   user@localhost on gssm
  239 Query     SHOW VARIABLES
  239 Query     SHOW COLLATION
  239 Query     SET character_set_results=NULL
  239 Init DB   db
  239 Query     SET autocommit = 0
  239 Query     SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ
  239 Query     BEGIN
  239 Query     INSERT INTO TestTable (KeyField, Value) VALUES ('foo', 'bar')
  </code></pre>
  
  <p>Of course I should fix my code, so that no unhandled exception occurs, but is there a way to prevent Mysql from doing this?</p>
  
  <p>Thanks!</p>
  
  <p>Chris</p>