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 181351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:44:53+00:00 2026-05-11T14:44:53+00:00

we have a problem to use TransactionScope. TransactionScope get to us very good flexibility

  • 0

we have a problem to use TransactionScope. TransactionScope get to us very good flexibility to use transactions across our Data Access Layer. On this way we can use transactions implicit or explicit. There are some performance boost again ADO.NET transactions, but at this time this is not really problem. However we have problem with locking. In example code below, although isolation level is set to ReadCommitted, it is not possible to make Select SQL statement from other client on table testTable, until the main transaction (in Main method) will be committed, because there is lock on whole table. We also tried to use only one connection across all methods, but same behavior. Our DBMS is SQL Server 2008. Is there something what we didn’t understood?

Regards Anton Kalcik

See this sample code:

class Program {     public class DAL     {         private const string _connectionString = @'Data Source=localhost\fsdf;Initial Catalog=fasdfsa;Integrated Security=SSPI;';          private const string inserttStr = @'INSERT INTO dbo.testTable (test) VALUES(@test);';          /// <summary>         /// Execute command on DBMS.         /// </summary>         /// <param name='command'>Command to execute.</param>         private void ExecuteNonQuery(IDbCommand command)         {             if (command == null)                 throw new ArgumentNullException('Parameter 'command' can't be null!');              using (IDbConnection connection = new SqlConnection(_connectionString))             {                 command.Connection = connection;                 connection.Open();                 command.ExecuteNonQuery();             }         }          public void FirstMethod()         {             IDbCommand command = new SqlCommand(inserttStr);             command.Parameters.Add(new SqlParameter('@test', 'Hello1'));              using (TransactionScope sc = new TransactionScope(TransactionScopeOption.Required))             {                 ExecuteNonQuery(command);                 sc.Complete();             }         }          public void SecondMethod()         {             IDbCommand command = new SqlCommand(inserttStr);             command.Parameters.Add(new SqlParameter('@test', 'Hello2'));              using (TransactionScope sc = new TransactionScope(TransactionScopeOption.Required))             {                 ExecuteNonQuery(command);                 sc.Complete();             }         }     }      static void Main(string[] args)     {          DAL dal = new DAL();         TransactionOptions tso = new TransactionOptions();         tso.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;          using (TransactionScope sc = new TransactionScope(TransactionScopeOption.Required,tso))         {             dal.FirstMethod();             dal.SecondMethod();             sc.Complete();         }     } } 
  • 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. 2026-05-11T14:44:54+00:00Added an answer on May 11, 2026 at 2:44 pm

    I don’t think your issue has anything to do with the .NET TransactionScope concept. Rather, it sounds like you’re describing the expected behavior of SQL Server transactions. Also, changing the isolation level only affects ‘data reads’ not ‘data writes’. From SQL Server BOL:

    ‘Choosing a transaction isolation level does not affect the locks acquired to protect data modifications. A transaction always gets an exclusive lock on any data it modifies, and holds that lock until the transaction completes, regardless of the isolation level set for that transaction. For read operations, transaction isolation levels primarily define the level of protection from the effects of modifications made by other transactions.’

    What that means is that you can prevent the blocking behavior by changing the isolation level for the client issuing the SELECT statement(s). The READ COMMITED isolation level (the default) won’t prevent blocking. To prevent blocking the client, you would use the READ UNCOMMITTED isolation level, but you would have to account for the possibility that records may be retrieved that have been updated/inserted by an open transaction (i.e. they might go away if the transaction rolls back).

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

Sidebar

Related Questions

i have problem use link_to_remote link_to_remote document example say link_to_remote Delete this post, :update
Ok I have this problem I'm trying to use Jquery to load a partial
I'm doing a Microsoft Surface Application and I have this problem: I use the
i have problem with load data from Database i use Primefaces (or other use
I have this problem: if I use a uidatepicker, everything goes fine: I have
I have a problem when I use user control to get div tag from
regarding to this question , i have a problem if use that query for
I have found a problem with use JQuery timeout, i have a page with
I have problem with setting proper charset on my jsf pages. I use MySql
In a couple of scripts that I use I have problem that is intermittent.

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.