Professional Web Applications Themes

connection pooling error - ASP.NET General

I've created a data access layer for a .NET web application. I'm using C# and framework 1.1. I'm getting an error from time to time when I close a connection saying: System.InvalidOperationException: A connection pooling error has occurred. It doesn't happen each time, the exception is thrown randomly. The big problem is that the connection is left active in the pool. After a short period of time, the pool is filled up and people can't access the site. Has anyone ever run into this before? Any ideas on how I might correct the problem? Any help is greatly appreciated. Chris ...

  1. #1

    Default connection pooling error

    I've created a data access layer for a .NET web
    application. I'm using C# and framework 1.1. I'm getting
    an error from time to time when I close a connection
    saying: System.InvalidOperationException: A connection
    pooling error has occurred.

    It doesn't happen each time, the exception is thrown
    randomly. The big problem is that the connection is left
    active in the pool. After a short period of time, the
    pool is filled up and people can't access the site.

    Has anyone ever run into this before? Any ideas on how I
    might correct the problem? Any help is greatly
    appreciated.

    Chris Szabo.
    Chris Guest

  2. #2

    Default Re: connection pooling error

    Can post some code? How are you accessing and releasing your connection??

    "Chris Szabo" <com> wrote in message
    news:26bc01c36674$55f365c0$gbl... 


    Frank Guest

  3. #3

    Default Re: connection pooling error

    Sure... here's some code.

    private void killConn()
    {
    if (cmdSQL.Connection != null)
    {
    try
    {
    cmdSQL.Connection.Close();
    cmdSQL.Connection.Dispose();
    }
    catch ( Exception e )
    {
    l.writeException ( e );
    }
    }
    }

    public SqlCommand cmdSQL
    {
    get
    {
    if ( _cmdSQL == null )
    _cmdSQL = new SqlCommand ( );

    if ( _cmdSQL.Connection == null )
    _cmdSQL.Connection = new SqlConnection(connString);

    if ( _cmdSQL.Connection.ConnectionString == null ||
    _cmdSQL.Connection.ConnectionString==String.Empty )
    _cmdSQL.Connection.ConnectionString = connString;

    if ( _cmdSQL.Connection.State ==
    ConnectionState.Closed )
    {
    try
    {
    _cmdSQL.Connection.Open ( );
    }
    catch ( Exception e )
    {
    l.writeException ( e );
    }
    }
    return _cmdSQL;
    }
    }
     
    your connection?? 
    in message [/ref]
    getting [/ref]
    left [/ref]

    >
    >
    >.
    >[/ref]
    Chris Guest

  4. #4

    Default Re: connection pooling error

    Hmm... some things to consider..

    You could use the "Singleton" pattern and have a static connection that gets
    reused because really - you can have multiple operations happen over one
    connection. if you do this, everytime before you make a SQL call, make sure
    the connection is open, if it's not - then open it.

    but the first thing that came to mind is that you are trying to manually
    ..Dispose() of the object, and for connection pooling - it seems to be all or
    nothing. Either you control all connections opening or closing - or you let
    cp handle it.. So I'd say get comment out the .Dispose() and see if this
    still happens..

    And if the database is SQL2K - you can run the SQL Profiler and watch the
    connections and see what happens every time there is a new connection..

    hth

    "Chris Szabo" <com> wrote in message
    news:013101c36679$bb1fdf50$gbl... 
    > your connection?? 
    > in message [/ref]
    > getting [/ref]
    > left [/ref]
    > I 
    > >
    > >
    > >.
    > >[/ref][/ref]


    Frank Guest

  5. #5

    Default Re: connection pooling error

    Okay, I'll give that a try. Can you fill me in on
    the "Singleton" pattern? I've actually been trying to
    accomplish this since we expect massive amounts of traffic
    on the site. I haven't been able to come up with anything.

    Thanks,
    Chris Szabo.
     
    connection that gets 
    happen over one 
    SQL call, make sure 
    trying to manually 
    it seems to be all or 
    closing - or you let 
    and see if this 
    Profiler and watch the 
    new connection.. 
    in message [/ref]
    || [/ref]
    _cmdSQL.Connection.ConnectionString==String.Empty ) [/ref]
    ConnectionState.Closed ) 
    >> your connection?? 
    >> in message 
    >> getting [/ref][/ref]
    connection 
    >> left [/ref][/ref]
    the [/ref][/ref]
    how [/ref]
    >
    >
    >.
    >[/ref]
    Chris Guest

  6. #6

    Default Re: connection pooling error

    Kill cmdSQL.Connection.Dispose(); GC issue, with Dispose() left alive
    until blah blah blah maybe?


    "Chris Szabo" <com> wrote in message
    news:013101c36679$bb1fdf50$gbl... 
    > your connection?? 
    > in message [/ref]
    > getting [/ref]
    > left [/ref]
    > I 
    > >
    > >
    > >.
    > >[/ref][/ref]


    MS Guest

  7. #7

    Default Re: connection pooling error

    I've modified the code as follows and I'm still getting
    the same error. I can actually step through it, verify
    that _cmdSQL is not null, .Connection is not null, and the
    state is open. When I reach the try catch block an
    exception is still thrown, A connection pooling error has
    occurred.

    private void killConn()
    {
    if ( _cmdSQL != null )
    {
    if ( _cmdSQL.Connection != null )
    {
    if ( _cmdSQL.Connection.State !=
    ConnectionState.Closed )
    {
    try
    {
    _cmdSQL.Connection.Close();
    }
    catch ( Exception e )
    {
    l.writeException ( e );
    }
    }
    }
    }
    }

    Any more ideas...?
     
    traffic 
    anything. 
    >connection that gets 
    >happen over one 
    >SQL call, make sure 
    >trying to manually 
    >it seems to be all or 
    >closing - or you let 
    >and see if this 
    >Profiler and watch the 
    >new connection.. 
    >in message [/ref]
    >|| [/ref]
    >_cmdSQL.Connection.ConnectionString==String.Emp ty ) [/ref]
    >ConnectionState.Closed ) [/ref][/ref]
    releasing [/ref][/ref]
    wrote [/ref]
    >connection [/ref]
    >the [/ref]
    >how 
    >>
    >>
    >>.
    >>[/ref]
    >.
    >[/ref]
    Chris Guest

Similar Threads

  1. Connection Pooling Error
    By CRoesener in forum Coldfusion Database Access
    Replies: 0
    Last Post: June 8th, 02:57 PM
  2. Connection Pooling
    By Trevor Hartman in forum Coldfusion Server Administration
    Replies: 5
    Last Post: May 24th, 07:18 PM
  3. Replies: 0
    Last Post: April 15th, 04:00 PM
  4. Oracle connection pooling
    By Lenny Shprekher in forum ASP.NET Web Services
    Replies: 0
    Last Post: December 9th, 04:22 PM
  5. Connection Pooling
    By RunneR in forum ASP Database
    Replies: 3
    Last Post: November 8th, 03:21 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139