Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Already opened DataReader
Message
De
12/03/2011 14:01:18
 
 
À
12/03/2011 06:32:01
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01503339
Message ID:
01503485
Vues:
31
>If the connection goes out of scope without being explicitly closed it will not be returned to the pool of available connections until the Dispose() is called - which, in turn, will not happen until the GC gets around to it - potentially quite a long time. (Actually that is a bit of an over-simplification - there are circumstances where it might be reclaimed but if those circumstances occur there's something wrong anyway)
>
>If you do open a connection explicitly (rather than, as Bonnie rightly suggests, relying on higher level objects to handle it implicitly) the safest option is:
Using sc As New SqlConnection(connectionString)
>  sc.Open()
>  'Grab data
>End Using
>
which will guarantee that the connection is closed (and thus returned to the pool) when the block is exited. This will be true even if an exception is thrown within the block.

Thanks, I will check it out and provide a follow up on this.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform