G
Garry Greer
We're trying to determine which is the best method for closing up
sqlconnections & datareaders while using Application Blocks (.close or
..dispose?). There are a significant amount of articles that have conflicting
opinions. Some say NOT to use .dispose because the connection will be
removed from the connection pool, others say this is not true. Some say to
use .close & let everything be garbage collected. I'd say it's about 50/50
from the pages I've read. We'd like to close the connection but have it
available in the pool.
The Application Blocks sample code looks like this:
Dim connection As New SqlConnection("myConnection")
connection.open
' do some stuff
If Not connection Is Nothing Then
CType(connection, IDisposable).Dispose() ' as opposed to
connection.close
End If
Comments?
sqlconnections & datareaders while using Application Blocks (.close or
..dispose?). There are a significant amount of articles that have conflicting
opinions. Some say NOT to use .dispose because the connection will be
removed from the connection pool, others say this is not true. Some say to
use .close & let everything be garbage collected. I'd say it's about 50/50
from the pages I've read. We'd like to close the connection but have it
available in the pool.
The Application Blocks sample code looks like this:
Dim connection As New SqlConnection("myConnection")
connection.open
' do some stuff
If Not connection Is Nothing Then
CType(connection, IDisposable).Dispose() ' as opposed to
connection.close
End If
Comments?