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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:50:55+00:00 2026-05-16T01:50:55+00:00

I did a simple test to understand how transactions work in .net Sample code

  • 0

I did a simple test to understand how transactions work in .net

Sample code on which my transaction test was done is

_sqlHelper = new SqlHelper(true);
try
{
    _sqlHelper.ExecuteNonQuery(SpName.sp_UpdateRoomStatus.ToString()
        , Parameters.SqlParam<int?>("DepartmentId", this.DepartmentId, SqlDbType.Int)
        );

    _sqlHelper.ExecuteNonQuery(SpName.sp_UpdateRoomStatus.ToString()
        , Parameters.SqlParam<int?>("DepartmentId", this.DepartmentId, SqlDbType.Int)
        );

    _sqlHelper.CommitTransaction();
}
catch (SqlHelperException ex)
{
    _sqlHelper.RollBackTransaction();
}

Description about the test

When I writes new SqlHelper(true); a new transaction starts internally and connection has been created and opened to database.

_sqlHelper.ExecuteNonQuery(SpName.sp_UpdateRoomStatus.ToString()
    , Parameters.SqlParam<int?>("DepartmentId", this.DepartmentId, SqlDbType.Int)
    );

Now above function executes my procedure and do changes in a database.

I wrote same function call twice to execute procedure two times. This procedure do insertion in database. This procedure contains 3 insert queries in 3 different tables.
Now I marked breakpoint on both function calls.

As soon as control comes on 1st breakpoint I simply lets its processing do which means 1st procedure has done insertion.

Now I unplugged my LAN wire since DB was on remote system. Which means connection lost. Hence transaction to be rolledback.

Now When I verified database after the whole process completed. I found data to be in consistent state hence proving that transaction is working.

I am confused at this moment that where did an actual insertion took place from 1st procedure call, since procedure executed successfully. How sql server get notified that transaction was going on and rollback has to be taken place.

It seems as if connection was established to database notifying that connection contains transaction and should get rolled back if connection gets lost.

Hence also stating that Changes made are maintained at Database rather than .net environment.

  • 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-16T01:50:56+00:00Added an answer on May 16, 2026 at 1:50 am

    The database knows that the connection and the changes should be in a transaction – the actual changes and original data are stored in the database transaction log. When the transaction isn’t properly committed and the connection is lost, the database automatically rolls back the transaction.

    Basically, in SqlTransactions (not distributed) .Net does nothing clever, it is all handled by the database.

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

Sidebar

Ask A Question

Stats

  • Questions 494k
  • Answers 494k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer At last I've got it to work. I've now put… May 16, 2026 at 11:08 am
  • Editorial Team
    Editorial Team added an answer That will give you an IEnumerable<ObservableCollection<Tool>>. It willprobably only have… May 16, 2026 at 11:08 am
  • Editorial Team
    Editorial Team added an answer In Oracle a user is a schema (USER=SCHEMA). You can… May 16, 2026 at 11:08 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm quite new to this (understanding the WP Guts), and I wanted to understand
I'm new to Umbraco and I like it so far, I understand how it
I've set up a simple, single-service server which has been working just fine with
Can anybody help me for a deadlock in SQL Server 2005? For a simple
Yes, I did read the 'Related Questions' in the box above after I typed
I've come to bother you all with another probably really simple C question. Using
How can the following simple implementation of sum be faster? private long sum( int
i'm stuck with a seemingly simple problem in mathematics: i need to rotate points
I have been sourcing for codes/tutorials on iPhone UITextField. I came across its sample
I tried to set up my togglebutton properties layout using style.xml. Here's my code:

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.