TransactionScope problem?
Posted by: Dan Bui
Date: July 18, 2006 12:57PM

Hello everyone,

I'm using NET 2.0 developing in C# connecting to a Mysql database with ADO.net (MySQL Connector/Net -- Mysql.data.MySqlClient). I want to use the new TransactionScope methods to control my transactions, but I'm not having much luck.

Can anyone tell me why the following code won't rollback? I thought all i had to do was NOT call complete().

-Dan



using (TransactionScope ts = new TransactionScope())
{
string connectionString = ConfigurationManager.AppSettings["DATABASECONNECTIONSTRING"];
MySqlConnection mySqlConnection = new MySqlConnection(connectionString);
mySqlConnection.Open();
MySqlCommand mySqlCommand = new MySqlCommand();
mySqlCommand.Connection = mySqlConnection;
mySqlCommand.CommandText = @"INSERT INTO tablename VALUES
('one', 'two', 'three');";
mySqlCommand.ExecuteNonQuery();
mySqlConnection.Close();

throw new Exception("why won't you roll back?");

}



Edited 1 time(s). Last edit at 07/18/2006 12:58PM by Dan Bui.

Options: ReplyQuote


Subject
Written By
Posted
TransactionScope problem?
July 18, 2006 12:57PM
July 25, 2006 07:09AM
August 01, 2006 08:44AM
August 06, 2006 10:08AM
August 07, 2006 11:35PM
September 20, 2006 11:29AM
September 26, 2006 08:02AM
September 28, 2006 06:51PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.