?
Solved

TransactionScopeOption.Suppress does not work

Posted on 2014-07-17
1
Medium Priority
?
743 Views
Last Modified: 2014-07-17
I have a transactionscope like this:

 using (TransactionScope tran = new TransactionScope())
                {
                    try
                    {

                          //method1
                          //method2
                         tran.Complete();
                     }
                     catch (Exception ex)
                     {
                          //handle exception
                     }

}

In method1 I call a SP and catch any exceptions which I want to log and commit

So within the catch part of another try..catch within method1 I have the following code.

catch (Exception ex)
                {

                        using (var scope = new TransactionScope(TransactionScopeOption.Suppress))
                        {
                            Conx.InsertLog( ex.Message, ex.StackTrace);
                            scope.Complete();
                        }

I understood that the second transactionscope should be unaffected by the ambient transcationscope...and when I step through the code errors are being logged. However they all seem to be rolled back by the ambient TransactionScope. What am I doing wrong??
0
Comment
Question by:Paulmc999
1 Comment
 
LVL 2

Accepted Solution

by:
Paulmc999 earned 0 total points
ID: 40201513
Solved problem, I was using the same DB conx in both. When I used a new connection in second transaction it worked.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question