Transaction Rollback
Posted by:
Eric Klein
Date: April 17, 2009 09:01AM
Are there any known issues with Transactions in .net 2.0? I have the following code that I have set up as a demo to try and fire a rollback. But even though I get an error and it hits the rollback code the data is committed to the datebase
Dim myConnection As New MySqlConnection(_Connection.ConnectionString)
myConnection.Open()
Dim myCommand As MySqlCommand = myConnection.CreateCommand()
Dim myTrans As MySqlTransaction
myTrans = myConnection.BeginTransaction()
myCommand.Connection = myConnection
myCommand.Transaction = myTrans
Try
ExecuteCommand.CommandText = "sp_UpdateContract"
ExecuteCommand.CommandType = CommandType.StoredProcedure
ExecuteCommand.Parameters.AddWithValue("@ContractID", ContractID)
ExecuteCommand.Parameters.AddWithValue("@Indefinite", Indefinite)
ExecuteCommand.Parameters.AddWithValue("@StartDate", StartDate)
ExecuteCommand.Parameters.AddWithValue("@EndDate", EndDate)
ExecuteCommand.Parameters.AddWithValue("@NoLimit", NoLimit)
ExecuteCommand.Parameters.AddWithValue("@NumItems", NumberToWrite)
ExecuteCommand.Parameters.AddWithValue("@HasObjectives", HasObjectives)
_DB.ExecuteQuery(ExecuteCommand)
myCommand.CommandText = "raiseerror('Artificial Error')"
myCommand.ExecuteNonQuery()
myTrans.Commit()
Catch ex As Exception
myTrans.Rollback()
Finally
myConnection.Close()
End Try
I have checked the table and it usesInnoDb engine.
Server Information:
MySQL Version: 5.0.45
Client Information
MySQL Client Version 5.1.11
Subject
Views
Written By
Posted
Transaction Rollback
3649
April 17, 2009 09:01AM
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.