locked
Implicit and Explicit nested tranasctions in ADO .net RRS feed

  • Question

  • I have a Existing code which uses Explicit transaction (Connection.BeginTransaction()) for performing database operations.

    I had also used implicit transaction (using TransactionScope) in my code. I have few pieces of code where Explicit transactions are nested inside a Implicit transaction.

    I wiill like to know whether i should avoid this approach and use only either all Implicit/ Explicit transaction in nested transaction, so that there is no mix of implicit/explicit transaction in a nested transaction.

    Any help will be greatly appreciated.


    Abhinav Galodha
    Monday, February 7, 2011 2:41 PM

Answers

  • Hi Agalo,

    Welcoome to ado.net managed providers forum.

    You should not need to have the explicit transactions inside the implicit transaction.

    The methods in the implicit transaction will add the transaction automatically.

    If there is only one method to against data source I suggest the explicit transaction.

    Or if there are multiple methods and effect with eachother I suggest the implicit transaction.

    There is a sample to implementing transactionscope in c#:

    http://www.codeproject.com/KB/dotnet/TransactionScope20.aspx

    I hope that would be help you.

    Have a good day. 


    If it's helpful for you, Please vote or mark. Thank you!

    David Peng [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Jackie-Sun Tuesday, February 15, 2011 6:05 AM
    Wednesday, February 9, 2011 2:44 AM

All replies