asp.net - Not calling SqlConnection.Close() in Windows Forms - Why does it work sometimes -


a friend of mine hosting asp.net 2.0 app @ home until moved , offered host on own win7/iis7/sqle2008r2 server.

when put code on server, after few requests error:

timeout expired. timeout period elapsed prior obtaining connection pool. may have occurred because pooled connections in use , max pool size reached.

first turned max pool size temporarily "fix" problem. took closer @ code. turned out never called sqlconnection.close(). added closing , removed max pool size connection strings, , problem solved.

i asked him how solved problem, , if he'd somehow increased max pool size per default in server's default web.config or something. replied ".net garbage collection". relying on garbage collection close database connections, , on server worked. on mine didn't.

can explain why? he's on vacation don't want bother him asking him details on versions etc, guess running win2k8.

jeff atwood has wonderful article thing, highly recommend read.

relying on .net garbage collection close sql connections no-no. sqlconnection.close(), dispose() should called, close() @ least. note using keyword take care of disposing objects automatically (example).

it's irresponsible , silly rely on gc anything. that's ignoring memory , saying "oh, when user runs out of ram, can restart! : d" .

in nut shell, code not working on new deployment site not fault. in case, it's coders irresponsible sqlconnection handling.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -