Re: what are the ways to ensure a sql connection is close?

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Karl (_at_)
Date: 10/26/04


Date: Mon, 25 Oct 2004 22:50:29 -0400

You can call Dispose() on the SQlConnection.....this will ensure that the
connection is closed, and won't cause any harm if it already is (it itself
checks to see the state of the connection).

All you need to make sure is that you aren't calling dispose() on a null
reference (of course).

Karl

-- 
MY ASP.Net tutorials
http://www.openmymind.net/
"Asha" <Asha@discussions.microsoft.com> wrote in message
news:D75D33A5-354A-4AC8-9569-E2941989FA2D@microsoft.com...
> greetings, besides using objconn.State() to find out if a sql connection
is
> close or open, is there any other way to accomplish this task? thanks in
> advance.
> anywhere is sql server or the machine to tell this?
>
>


Relevant Pages

  • Re: VS2005 and SQL Express: Internal .Net Framework Data Provider
    ... connection object you use. ... public void CreateConnection{ ... // Close first and dispose the existing data reader is there ... release resources used by the object ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: C# and GDI Resources
    ... interface use unmanaged resources; i.e. they end up being a wrapper to ... The rule is, if the object has a Dispose or Close method, make SURE you ... your class opens a database connection when an object is instanciated ... method would make sure to Dispose the database connection. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: SqlConnection.Dispose close connection?
    ... The fact is that the garbage collector in c# is a generational collector. ... But a connection could be kept for longer use of course; ... Dispose calls Close anyway. ... By doing so you ensure that the unmanaged resource (i.e., ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: 2 ways to close a connection
    ... that the fix did not come from calling dispose instead of close. ... > resources used by the object. ... It only closes the connection. ... > Explicitly disposing any object that uses unmanaged resources as soon as you ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Connection pooling...
    ... Lets say your class is "C" and the expensive objects it holds are A and B ... Dispose, and B was say an instance of a COM object. ... In that sense, calling dispose on a Connection object, does NOT Guarantee ... (WHEEZE COUGH COUGH!!) ...
    (microsoft.public.dotnet.framework.adonet)