B
Big D
Does calling the sqlConnection.dispose method close any open connections or
must you explicitly close them first?
-MCD
must you explicitly close them first?
-MCD
Kevin Yu said:I didn't mean that we should never call .Dispose in our code. I meant that
we have to avoid calling it explicitly in our code, and leave the .Dispose
to the GC.
Sami has provided us with a good suggestion with "using" statement. So that
we ensure the object is disposed.
Dmitriy Lapshin said:By the way - I've heard somewhere that calling Dispose() on an SqlConnection
instance removes this connection from the connection pool, whereas Close()
just returns the connection to the pool.
Dmitriy Lapshin said:By the way - I've heard somewhere that calling Dispose() on an
SqlConnection
instance removes this connection from the connection pool, whereas Close()
just returns the connection to the pool.