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
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
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.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.