Home   |   QuickStart Welcome   |   ASP.NET   |   Web Services   |   How Do I...?   
  |   I want my samples in...      

How Do I...? Common Tasks QuickStart Tutorial

How can I get the outcome of a transaction?



In order to get the outcome of the transaction you need to perform a VolatileEnlist in the transaction. The outcome events are called on the IEnlistmentNotification interface

		

        public void Arm()
        {
            transaction = Transaction.Current;
			// Enlist in the transaction
            transaction.VolatileEnlist(this, false);
        }
        public void Commit(IEnlistment enlistment)
        {
            ReportTransactionStatus ("commit", transaction);
            enlistment.EnlistmentDone();
            transaction = null;
        }
        
        public void Rollback(IEnlistment enlistment)
        {
            ReportTransactionStatus ("rollback", transaction);
            enlistment.EnlistmentDone();
            transaction = null;
        }
    
        public void InDoubt()
        {
            ReportTransactionStatus ("InDoubt", transaction);
            transaction = null;
        }
        ...

C#


The following sample code enlists in the transaction and prints out the outcome of the transaction. No Source or Sample to display.


Microsoft .NET Framework SDK QuickStart Tutorials Version 2.0
Copyright � 2004 Microsoft Corporation. All rights reserved.