Closing a connection which is in Session state and the connection is still open in Enterprise Manager

Posted on 2005-05-11
Last Modified: 2013-12-03
Hi, i've got a web application which creates and open a connection in the page load and then stores it in the session state.

the problem is that when i want to close the connection :
SqlConnection mySqlConnection = (SqlConnection) Session["mySqlConnection"];
Session["mySqlConnection"] = null;

it is still visible and open in Enterprise Manager

the real problem is that when there are a lot of activity on this application, all the connections stay opened and so the pool becomes full and noone can connect =/

what's the problem ?

Question by:ennixo
    LVL 7

    Accepted Solution

    you should open and close the connection as fast as possible.  I wouldnt store an open connection in the session.  You should only have the connection open long enough to make the database call and return your data.  Then close the connection and manipulate your data in whatever way you need.
    LVL 5

    Author Comment

    i agree and i'll change this, do you think the fact to store it in the Session state can make it "unclosable" ?
    LVL 5

    Author Comment

    i changed it, now i don't see the connections in Enterprise Manager since it is closed just after executing commands.

    thank you =)
    LVL 7

    Expert Comment

    no problem.  Im glad that I could help.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
    IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now