Page 1 of 1

Transaction Scope Question

Posted: Fri 19 Mar 2010 15:35
by Zero-G.
Hey

Using DotConnect for mySQL version BETA 5.x.102

So, I use in my VB.NET Environment Transaction Scope with code like this:

Code: Select all

            Dim tScope As New System.Transactions.TransactionScope
            Try
                Fakturieren()
                tScope.Complete()
            Catch ex As Exception
                IntelliSoft.myMessageBox.OfficeBox.Show("Es ist ein Fehler aufgetreten" & Environment.NewLine & _
                                ex.Message, VisualOPTNet.MessageCaption, _
                                MessageBoxButtons.OK, IntelliSoft.myMessageBox.OfficeMessageBoxIcon.Error)
            Finally
                tScope.Dispose()
            End Try
Where in the Sub of "Fakturieren" is a SP called, which has a return value.
With this returned value, I go on with working.
OK - So, when AFTER calling the SP an error occurs, than tScope.Complete is NOT CALLED. - But the changes made by the SP, are still set.
Is there any kind of information about this?

THX

Posted: Mon 22 Mar 2010 17:54
by Shalex
It seems like you are opening the connection object outside of your TransactionScope. As a result, the connection is not enlisted in the current transaction context. Try enlisting your connection explicitly by executing the following code inside TransactionScope:

Code: Select all

connection.EnlistTransaction(Transaction.Current);