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

  • Home
  • SEARCH
  • 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 91549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:02:50+00:00 2026-05-10T23:02:50+00:00

How do you manage your database connections in your ASP.Net application? My understanding tells

  • 0

How do you manage your database connections in your ASP.Net application?

My understanding tells me the ‘best’ way is to open a connection, make a query, close the connection – and do that multiple times because connection pooling makes the cost negligable.

The problem comes when I have a DAL where each method looks after its own connection. E.G.

 User x = DAL.GetUserDetails(); Customer y = DAL.GetCustomer(); 

This is fine until we start talking about TransactionScope

 using (TransactionScope t.... { DAL.UpdateCustomer(y); DAL.UpdateUser(x); t.Complete(); } 

ASP.Net wants to now use DTC because (I’m guessing) there are multiple connections involved.

Someone is going to say ‘Cache the connection somwhere’ but I need to explicitly destroy the connection because of the way I am managing security (execute as / revert) and I don’t want to have to make a call on every page to do that because someone will forget to make the call. I could also pass the connection into each method but thats not ideal because the page has to manage a connection.

Am I making sense or have I missed something fundamental here?

  • 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-10T23:02:51+00:00Added an answer on May 10, 2026 at 11:02 pm

    I was reading somewhere and I don’t remember where that Microsoft was going to address that when you have two connections to the same DB that they would not escalate to DTC which would make this problem go away.

    Until then what we did was to develop our TransactionScope, our DALs would then ask the TS for a new connection, and when we disposed the TS it would close the connection.

    The connections were stored in LogicalCallContext, although I would look at using HTTP Context instead. I left the company before the app went live but from what I’ve heard they haven’t had any issues.

    so you’d have

    using (CustomTS.New()) {  CustomerDal.Update()  userDal.Update() } 

    CustomTS had a static method that would get the current transaction and connection.

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

Sidebar

Related Questions

is there a best way to manage a form in WPF application which has
How do you manage your sql server database build/deploy/migrate for visual studio projects? We
I followed this way. To create a workspace to manage your source-controlled files 1.
How do you organize and manage your helper objects like the database engine, user
I was trying to upload the database of my ASP.NET website. On the local
In order to fully use LinqToSql in an ASP.net 3.5 application, it is necessary
The Database Forge Class contains functions that help you manage your database. It can:
I am using pyodbc to manage my database connections. I am attempting to connect
I understand that spring can manage your sessions for you, if configured like so:
How do you prefer to manage the contents of your site , XSLT ,

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.