Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7055901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:48:14+00:00 2026-05-28T03:48:14+00:00

I want to roll back a transaction named scope but the inner transaction named

  • 0

I want to roll back a transaction named “scope” but the inner transaction named scope2 should not roll back. But they both roll back!!! The option TransactionScopeOption.Suppress doesn’t work…

I already enabled DTC and I’m using Visual Studio 2010 with .net 4.0 and Microsoft SQl Server 2008.
What’s wrong here???

using (SqlConnection conn = new SqlConnection(@"Data Source=.\DEVELOPER;Initial Catalog=TestDatenbank;Integrated Security=sspi"))
        {

            using (TransactionScope scope = new TransactionScope())
            {

                conn.Open();

                SqlCommand cmd = new SqlCommand();
                cmd.Connection = conn;

                cmd.CommandText = "UPDATE Orders SET ID='111'";
                cmd.ExecuteNonQuery();


                using (TransactionScope scope2 = new TransactionScope(TransactionScopeOption.Suppress))
                {

                    SqlCommand cmd1 = new SqlCommand();
                    cmd1.Connection = conn;

                    cmd1.CommandText = "UPDATE Orders SET OrderName='aaa'";
                    cmd1.ExecuteNonQuery();


                    scope2.Complete();
                }


                //scope.Complete();

            }

        }

Thanks alot for your answers!

I finally works!!!!

using (SqlConnection conn = new SqlConnection(@"Data Source=.\DEVELOPER;Initial Catalog=TestDatenbank;Integrated Security=sspi"))
        {

            using (TransactionScope scope = new TransactionScope())
            {

                conn.Open();

                SqlCommand cmd = new SqlCommand();
                cmd.Connection = conn;

                cmd.CommandText = "UPDATE Orders SET ID='111'";
                cmd.ExecuteNonQuery();

                using (SqlConnection conn2 = new SqlConnection(@"Data Source=.\DEVELOPER;Initial Catalog=AdventureWorks;Integrated Security=sspi"))
                {
                    using (TransactionScope scope2 = new TransactionScope(TransactionScopeOption.Suppress))
                    {

                        conn2.Open();

                        SqlCommand cmd1 = new SqlCommand();
                        cmd1.Connection = conn2;

                        cmd1.CommandText = "UPDATE Henrik SET ID='111'";
                        cmd1.ExecuteNonQuery();


                        scope2.Complete();
                    }
                }


                //scope.Complete();

            }

        }

One strange thing is, when I delete the line scope2.Complete(); and replace //scope.Complete(); with scope.Complete(); I expected the following:

scope will be executed
scope2 will roll back

but actually:
scope will be executed
scope2 will also be executed

Any ideas???????

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:48:15+00:00Added an answer on May 28, 2026 at 3:48 am

    I don’t know for sure, but the reason could be that although you do suppress any ambient transaction by using suppress, you use the same connection as for the outer scope. Thus the connection already participates in a transaction (the outer one) and so all changes are bound to this. The fact that there is no ambient transaction present in the inner scope might not make a difference. In other words the suppress scope wouldn’t do anything here.

    You could try to run the inner logic in a TransactionScope using RequiresNew and with a new connection.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to roll back an iPod Touch 2nd gen from the 3.0 OS
I want to test the automatically rolling back of an transaction. Therefore, I implemented
I want to rollback a transaction which already committed, does JTA support this kind
I have a handful of elements I want to set roll overs on, how
I want to check the central limit with dices. Roll D dices. Sum the
Want the function to sort the table by HP but if duplicate HPs then
We want to use the Atomikos JTA Transaction Manager. We have a unit test
I want to compose operations that may fail, but there is a way to
I want to execute transactions in node-mysql (by executing queries START TRANSACTION, ROLLBACK, COMMIT).
I want to update some data column after inserting values. But it gives me

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.