|
-
July 25th, 2006, 09:26 AM
#1
TransactionScope !@#$
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?");
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|