CodeSmith Community
Your Code. Your Way. Faster!

Transaction not working

Latest post 02-15-2007 6:52 AM by andrecarrilho. 1 replies.
  • 02-15-2007 6:28 AM

    Transaction not working

    Hey

    I'm using using transactions in my code but it's not working when Rolling Back. Here is an example:

    try

    {

    TransactionManager trans = DataRepository.Provider.CreateTransaction();

    trans.BeginTransaction();

       try
       {
         
    // Update Entity1
          // Update Entity2

          // If I throw an exception here it should roolback the updates on Entity1 and Entity2 but it doesn't 
          throw new Exception("any exception");

         
    // Update Entity3

          trans.Commit();
       }
       catch (Exception ex)
       {

          trans.Rollback();
         
    throw new Exception(ex.Message);
       }
    }
    catch (Exception ex)
    {
      
    throw new Exception(ex.Message);
    }

     Does anyone know how to solve this?

    André da Silva Carrilho
    Filed under: , ,
    • Post Points: 5
  • 02-15-2007 6:52 AM In reply to

    Re: Transaction not working

    Hey...

    My bad... In the Updates I didn't put the trans object - Update(trans, entity).
    It's working know!

    Cheers

    André da Silva Carrilho
    Filed under: , ,
    • Post Points: 5
Page 1 of 1 (2 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems