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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:00:45+00:00 2026-06-13T22:00:45+00:00

Possible Duplicate: Transactions in .net I just wanted to know about Transaction in .net

  • 0

Possible Duplicate:
Transactions in .net

I just wanted to know about Transaction in .net using c# language. I have gone through different articles on the net. However, I came to know about transaction theoretically but I wanted to know the exact use of it in real time. For example when exactly should I use transactions in real time. Let’s suppose, I am writing code where I am doing some action on the click event of a link. Lets say, I am hitting the SQL connection to get some values. Should I use transaction there? If I am writing simple code, where I fetch values without using sql connection, should I use transactions there? What are the pros and cons of using Transactions. Getting theoritical knowledge is different, but I want to know the exact use of it. When to use when not to use. Can transactions be used in simple code? Any responses or links for even basic stuff about transactions are welcome.

  • 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-06-13T22:00:46+00:00Added an answer on June 13, 2026 at 10:00 pm

    I am hitting the SQL connection to get some values. Should I use
    transaction there?

    No, there are not need to use transactions, when you are not alter data in database.

    What are the pros and cons of using Transactions.

    As you said, you have learned various articles, So may be you have figure out the reason of using the transactions. Look all of these in concern of database.

    The advantages of three-tier applications in creating scalable and robust applications are made feasible by transaction processing systems. The ability to distribute the components that make up applications amongst separate servers without explicitly having to develop for that architecture is another advantage of transaction server processing. Transaction processing systems also ensure that transactions are atomic, consistent, isolated, and durable. This alleviates the developer from having to support these characteristics explicitly.

    Why Do We Need Transaction Processing?
    The Advantages Of Transaction Processing
     

    Can transactions be used in simple code?

    Yes, you can simply write code in C# using ADO.Net. (e.g. SQLTransaction class)

    e.g.

    SqlConnection db = new SqlConnection("connstringhere");
          SqlTransaction transaction;
    
          db.Open();
          transaction = db.BeginTransaction();
          try 
          {
             new SqlCommand("INSERT INTO TransactionDemo " +
                "(Text) VALUES ('Row1');", db, transaction)
                .ExecuteNonQuery();
             new SqlCommand("INSERT INTO TransactionDemo " +
                "(Text) VALUES ('Row2');", db, transaction)
                .ExecuteNonQuery();
             new SqlCommand("INSERT INTO CrashMeNow VALUES " +
                "('Die', 'Die', 'Die');", db, transaction)
                .ExecuteNonQuery();
             transaction.Commit();
    

    Reference:
    Performing a Transaction Using ADO.NET
    .NET 2.0 transaction model

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

Sidebar

Related Questions

Possible Duplicate: Entity Framework with NOLOCK I'm using EF4 and .Net 4 to load
Possible Duplicate: Django switching, for a block of code, switch the language so translations
Possible Duplicate: How do I make a request using HTTP basic authentication with PHP
Possible Duplicate: check whether internet connection is available with C# I just want to
Possible Duplicate: Extracting dollar amounts from existing sql data? I have a column in
Possible Duplicate: JSON serialization of c# enum as string I have two classes as
Possible Duplicate: Hibernate: different object with the same identifier value was already associated with
Possible Duplicate: SQL Server and connection loss in the middle of a transaction I
Possible Duplicate: How to keep the browser history in sync when using Ajax? I
Possible Duplicate: Difference of create Index by using include column or not using Edit:

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.