connection from asp.net to sqlserver2000 remains open and blocks other connections.

Discussion in 'ASP .Net' started by avnrao, Jun 21, 2004.

  1. avnrao

    avnrao Guest

    best way is to override dispose on that general class.. and you can call it
    explicitly or use using() block.
    deconstructor gets called when object is removed (i guess when GC is
    collecting the object)..

    destructors also be called when program exists. is your program existing
    here?
    Av.

    "z. f." <> wrote in message
    news:...
    > Hi,
    >
    > i use asp.net and i have a general class that manages database access
    > using
    > ado.net and sqlclient provider.
    > this class upon deconstructor closes connection to DB.
    >
    > it appears on sql 2000 manager when i look in management/current
    > activity/Process Info that my connections stays open and the number of
    > connections open is increasing each request.
    >
    > what am i missing / doing wrong here.
    > thanks for any input from your experience.
    >
    > z.
    >
    >
    avnrao, Jun 21, 2004
    #1
    1. Advertising

  2. avnrao

    Patrice Guest

    Do you have a message saying the connection pool is full ?

    Remember that finalization in .NET is not deterministic and here I suspect
    you still have a reference.

    I would close explicitely the DB connection as soon as I'm done with it.

    Patrice

    --

    "z. f." <> a écrit dans le message de
    news:...
    > Hi,
    >
    > i use asp.net and i have a general class that manages database access

    using
    > ado.net and sqlclient provider.
    > this class upon deconstructor closes connection to DB.
    >
    > it appears on sql 2000 manager when i look in management/current
    > activity/Process Info that my connections stays open and the number of
    > connections open is increasing each request.
    >
    > what am i missing / doing wrong here.
    > thanks for any input from your experience.
    >
    > z.
    >
    >
    Patrice, Jun 21, 2004
    #2
    1. Advertising

  3. avnrao

    z. f. Guest

    Hi,

    i use asp.net and i have a general class that manages database access using
    ado.net and sqlclient provider.
    this class upon deconstructor closes connection to DB.

    it appears on sql 2000 manager when i look in management/current
    activity/Process Info that my connections stays open and the number of
    connections open is increasing each request.

    what am i missing / doing wrong here.
    thanks for any input from your experience.

    z.
    z. f., Jun 21, 2004
    #3
  4. avnrao

    z. f. Guest

    well, since it's an aspx page, the program is aspnet.exe on win2k or
    w3wp.exe on win2003 and this process should stay in memory for long time.
    so i need to take care of my objects my self.
    thanx.




    "avnrao" <> wrote in message
    news:...
    > best way is to override dispose on that general class.. and you can call

    it
    > explicitly or use using() block.
    > deconstructor gets called when object is removed (i guess when GC is
    > collecting the object)..
    >
    > destructors also be called when program exists. is your program existing
    > here?
    > Av.
    >
    > "z. f." <> wrote in message
    > news:...
    > > Hi,
    > >
    > > i use asp.net and i have a general class that manages database access
    > > using
    > > ado.net and sqlclient provider.
    > > this class upon deconstructor closes connection to DB.
    > >
    > > it appears on sql 2000 manager when i look in management/current
    > > activity/Process Info that my connections stays open and the number of
    > > connections open is increasing each request.
    > >
    > > what am i missing / doing wrong here.
    > > thanks for any input from your experience.
    > >
    > > z.
    > >
    > >

    >
    >
    z. f., Jun 21, 2004
    #4
  5. ADO.NET manages connection pooling itself, If you do a close or dispose
    it does'nt really mean that connection to db server is closed. When you call
    connection.close or adapter.close, it actually closes connection to your
    applications
    object with ado.net, on the other hand ADO.NET is itself maintaining
    connections
    with database.
    Its very important to close both data reader and connection as soon as they
    are no longer needed. if you do not do this, they will go out of scope and
    the
    application will leak a connection and u'll see one more connection.

    check this msdn documentation for reference:
    http://msdn.microsoft.com/library/en-us/vbcon/html/vburfintroductiontoadoconnectiondesigntools.asp

    --
    Hope this helps,
    Zeeshan Mustafa, MCSD


    "z. f." <> wrote in message
    news:...
    > Hi,
    >
    > i use asp.net and i have a general class that manages database access

    using
    > ado.net and sqlclient provider.
    > this class upon deconstructor closes connection to DB.
    >
    > it appears on sql 2000 manager when i look in management/current
    > activity/Process Info that my connections stays open and the number of
    > connections open is increasing each request.
    >
    > what am i missing / doing wrong here.
    > thanks for any input from your experience.
    >
    > z.
    >
    >
    M. Zeeshan Mustafa, Jun 21, 2004
    #5
  6. It is not a good idea to let the finalizer (or deconstructor) close
    connections--it simply won't work. As others have said, close the
    connections explicitly.

    --
    ____________________________________
    William (Bill) Vaughn
    Author, Mentor, Consultant
    Microsoft MVP
    www.betav.com
    Please reply only to the newsgroup so that others can benefit.
    This posting is provided "AS IS" with no warranties, and confers no rights.
    __________________________________

    "z. f." <> wrote in message
    news:...
    > Hi,
    >
    > i use asp.net and i have a general class that manages database access

    using
    > ado.net and sqlclient provider.
    > this class upon deconstructor closes connection to DB.
    >
    > it appears on sql 2000 manager when i look in management/current
    > activity/Process Info that my connections stays open and the number of
    > connections open is increasing each request.
    >
    > what am i missing / doing wrong here.
    > thanks for any input from your experience.
    >
    > z.
    >
    >
    William \(Bill\) Vaughn, Jun 21, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tim Marsden
    Replies:
    11
    Views:
    956
    Steven Cheng[MSFT]
    Jun 3, 2004
  2. jobs
    Replies:
    2
    Views:
    886
  3. Terry Ledwith

    Dbase remains open after closing FP98

    Terry Ledwith, Aug 22, 2003, in forum: ASP General
    Replies:
    0
    Views:
    103
    Terry Ledwith
    Aug 22, 2003
  4. matt
    Replies:
    1
    Views:
    254
    George Ogata
    Aug 6, 2004
  5. Steven Taylor
    Replies:
    9
    Views:
    247
    Brian Candler
    Apr 27, 2009
Loading...

Share This Page