Should Dispose be invoked?

G

Guest

Quote from ADO.NET MOC, Module 2 - Connecting to Data Sources, p18:

"Calling the Dispose method removes the connection from the connection pool."

Does this mean that it's not advisable to call Dispose on a connection
unless the application is terminating? Otherwise, connection pooling is
programmatically disabled, in effect. Can anyone clarify this? Thanks =)
 
J

Jon Skeet [C# MVP]

jester said:
Quote from ADO.NET MOC, Module 2 - Connecting to Data Sources, p18:

"Calling the Dispose method removes the connection from the connection pool."

Does this mean that it's not advisable to call Dispose on a connection
unless the application is terminating? Otherwise, connection pooling is
programmatically disabled, in effect. Can anyone clarify this? Thanks =)

That's false - it's an urban myth.

See

http://groups.google.com/groups?selm=MPG.1b16f30b73488be98a988%
40msnews.microsoft.com&rnum=1
 
C

Cor Ligthert

Jester,

It is adviced (except with MS access) to close your connections when
datatransfer has ended. In the case of the connection using really dispose
instead of close and that as one of the exceptions while normally close is
sufficient.

I hope this helps,

Cor
 
M

Miha Markic [MVP C#]

Hi jester,

Just to add something to the thread:
As previously mentioned the Dispose does nothing to the pool and you really
should call it even if it does nothing at this time - it could change in the
future.
 

Ask a Question

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.

Ask a Question

Top