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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:42:01+00:00 2026-05-11T09:42:01+00:00

I would like to know, what would be the best way to manage a

  • 0

I would like to know, what would be the best way to manage a connection to a database in asp.net.

My application is built using an N-Tier architecture. The DAL consists of static classes with methods such as

Public Shared Sub Delete( _     ByVal connection As MyConnectionClass, _     ByVal contact_id As Integer, _     ByVal contact_timestamp As Date _ )      With connection.ProcParams         .Add(New StoredProcParam('p_contact_id', contact_id, OracleDbType.Int32))         .Add(New StoredProcParam('p_contact_timestamp', contact_timestamp, OracleDbType.Date))     End With      connection.Execute('PKG_DATA_ACCESS.DeleteContact')  End Sub 

The point to note here, is that I pass the connection to the DAL from the BLL.

Here are the points I have considered, but none of them seems alright to me, so I’m just asking for an advice.

Should I create the connections in the MasterPage, store it in an object, then pass it to my business objects as I create them (the thing I’m trying to avoid)

Should I create a connection using a static class and calling a method like CreateConnection on it, from the constructor of my business objects (Something I’d like, but I don’t want to have a connection per object, I’d like it to be shared for all instances of my objects, but since asp.net is multi-threaded, a static class doesn’t make sense to store connections)

Ideally, the solution should also work well in a Windows Forms environment (So no connection storing in session, and retrieving it with a static method in a class, for the current context)

  • 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-11T09:42:02+00:00Added an answer on May 11, 2026 at 9:42 am

    Don’t try to persist the connection at all. Instantiate it within each scope that you are using it. .Net will manage a pool of connections for you, wether in windows forms or in asp.net.

    Trying to hold onto the connection is a session object or in a master page will actually hurt performance, not to mention introduce other problems.

    From BC’s comment:

    connection strings must be equal strings to end up in the same pool.

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

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Put the InitializeComponent call back at the top where it… May 11, 2026 at 11:22 am
  • added an answer I think this is a better approach: NSString* escapedUrl =… May 11, 2026 at 11:22 am
  • added an answer I had to install Gallio 3.0.5 or better from http://www.gallio.org.… May 11, 2026 at 11:22 am

Related Questions

I would like to know what would be the best way to do unit
I would like to know what would be the impact of modifying web.config file
Accuracy Vs. Precision What I would like to know is whether I should use
I'm familiar with some of the basics, but what I would like to know
I would like to know what semaphores, messageQueues, etc... are active in my vxWorks
I would like to know what kind of tool you use for writing your
I would like to know what's the best technique to do single sign-on in
I would like to know what of the many XSLT engines out there works
I would like to know what are your practices when you test your classes.
I would like to know what is the difference between initializing a static member

Trending Tags

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

Top Members

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.