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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:17:55+00:00 2026-06-16T06:17:55+00:00

Hello i am new to Transaction Scope in C#. i have two insert queries

  • 0

Hello i am new to Transaction Scope in C#. i have two insert queries one belongs to UserAccountCreation where LoginCredentials are stored and another is Inserting Employee details with respective UserAccountID in Employee table as foreign key.

I have two different methods written to insert in UserAccount Table and after inserting into UserAccount the UserAccountID is feteched and Inserted into Employee table.
Situation is When UserAccount Creation succeeds and Employee Creation fails, then it must ROLLBACK. So, i would like to know whether we can use Transaction scope and in between call these two Insert Methods? and can we rollback these methods which have called in this scope if error occurs.
Sample Code:

private void CreateEmp()
{
  using (TransactionScope scope = new TransactionScope())
  {
    try
    {
        CreateUserAccount();
        CreateEmployee();
        scope.Complete();
    } 
    catch (TransactionAbortedException ex)
        {

    }
  }
}

Help Appreciated!
Thanks in Advance!

  • 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-16T06:17:57+00:00Added an answer on June 16, 2026 at 6:17 am

    you can call as many functions as you want in the transaction scope.
    If you want two methods can handle their own connections (open/use/close/dispose), yet they will silently become part of the ambient transaction without us having to pass anything in.

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

Sidebar

Related Questions

I have the following Test: public class EqualityTest { String one = new String(Hello
hello im new to python and have been reading over the documentation and am
Hello.Am new to ios development.What have to do for NSOpenPanel to work in the
Hello i am new in android and i am developing one application in which
Hello I am new to assembly and I'm struggling to get a two-part program
In Asp.net mvc3 razor I have: Ajax.ActionLink(Hello world, Hello, Say, new RouteValueDictionary(new { word
Hello im new here i am making a small tictactoe game where i have
Hello im new to bash scripting, i have a simple program which is not
I have an application that calls Email hello = new Email(appropriate constructor); hello.Email_Send(); I'm
class Hello @hello = hello def display puts @hello end end h = Hello.new

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.