From: David Cohen on
I have an AJAX page where I am doing a partial page refresh every 5 seconds.
My Page_Load() function contains the following:

SqlConnection conn = new SqlConnection(...);
conn.Open();
// database access stuff
conn.Close();

Even though I am closing the connection, I find that whenever this page
stays open for a long time, I get an "all pooled connections were in use and
max pool size was reached" error message. Does anybody know why?

From: Mike on
Hi David,

What exactly do you do between Open and Close? If you open a datareader,
you'll need to close it, too.

I have a couple of suggestions:
1. Cache a single connection in the Application variable
2. If you use your code, make sure that the conn.Close in the finally part
of a try catch.
3. As mentioned, close datareader in finally, also or use using(
SqlDataReader reader = cmd.ExecuteReader())..

Mike
http://www.homemadepride.com

"David Cohen" <ddcohen(a)gmail.com> a �crit dans le message de
news:D717176A-5D48-44B7-BC51-F52A7F0142FD(a)microsoft.com...
>I have an AJAX page where I am doing a partial page refresh every 5
>seconds. My Page_Load() function contains the following:
>
> SqlConnection conn = new SqlConnection(...);
> conn.Open();
> // database access stuff
> conn.Close();
>
> Even though I am closing the connection, I find that whenever this page
> stays open for a long time, I get an "all pooled connections were in use
> and max pool size was reached" error message. Does anybody know why?