Close and Dispose argument

I

Infinite_Recursion

This is something that I descovered is not only an issue with me, since
there has been so many posts on the issue. The real problem resides in the
fact that even Microsoft is not clear on the issue.
Long story short, here is an email conversation between me and Microsoft
that explains it...
---------


From: Microsoft Learning Contact Us <[email protected]>
To: (e-mail address removed)
Date: Thu, 3 Mar 2005 18:40:06 -0800
Subject: CST187877936ID - RE:Microsoft.Com ContactUS

Hello,

This is Grace of Microsoft Learning Customer Support. Your e-mail has been
transferred to us for proper handling
of your issue and we're truly sorry for not responding sooner with your
concern

I understand that you're reporting a documentation on the book "Microsoft
Official Course 2389B Programming with
Microsoft ADO.NET" module 2, page 18. We apologize for the inconvenience
this may have caused you.

I am currently working with my colleagues to investigate this issue. As soon
as one of my resources replies, I will
forward the information to you.

Thank you for bearing with us while we work to resolve your issue. If you
require other assistance, please do not
hesitate to write back.

Sincerely,

Grace
Microsoft Learning Customer Support

--- Original Message ---
From: (e-mail address removed)
To: (e-mail address removed)
Sent: Wed Mar 2 07:32:27 PST 2005
Subject: Microsoft.Com ContactUS


URL:http://msdn.microsoft.com/
DOM:msdnw
LANG:English (United States)
LOC:LB
BR:windows nt 5.1/mozilla/5.0 (windows; u; windows nt
5.1;/en-us,en;qSubject: Close() and Dispose() with connection pooling
Comment: This is a chaotic issue since in MSDN itself there are
contradictions. Weather SqlConnection.Dispose() returns or removes the
connections from the pool is still a debate. I have come to a conclusion
that it returns it to the pool after massive research and experimentation,
and after monitoring pooled connections in SQL server. The mistake I am
trying to report is in your book "Microsoft Official Course 2389B
Programming with Microsoft ADO.NET" module 2, p 18: "Calling the Dispose
method removes the conneciton from the connection pool". The thing is if we
cannot trust your books then what good is your documentation anyway, and why
should I pay your partners for training. I hope I recieve an answer on the
issue...
Site Bugs: in the book




From: Microsoft Courseware Support <[email protected]>
To: (e-mail address removed)
Date: Fri, 4 Mar 2005 16:23:01 -0800
Subject: FW: CST187877936ID - RE:Microsoft.Com ContactUS


Hello,



Your issue was forwarded to us here at Microsoft Courseware Support. The
discrepancy you describe has been previously reported. When such errors are
reported, the Courseware Support team formats and submits an error log
revision for review. The revisions that are accepted by a Subject Matter
Expert (SME) are then posted to the MCT Download Center. It is the Trainer's
responsibility to download these documents prior to delivery of a course and
share the information with their students.



Module 2, page 17 currently states: "When you close a connection, the flow
to and from the data source closes, but unmanaged resources used by the
connection object have not been released. If connection pooling is enabled,
the connection is released to the pool. Both the SqlConnection object and
the OleDbConnection object have a Dispose method to release the unmanaged
resources. Calling the Dispose method marks the connection for deletion from
the connection pool." Add to this statement: "An internal process
periodically examines each pool and destroys unused resources."



Also, Module 2, page 39, second paragraph, 2nd and 3rd sentences currently
state: "When a connection is disposed, the connection is deleted from
memory. It is not returned to the pool and is not available for reuse. When
the last connection in a connection pool is deleted, the pool is also
deleted from memory." These statements are incorrect and should be ignored.
When a SqlConnection object is disposed the underlying connection to the
database is still kept in the connection pool and can be used by other
SqlConnection objects.



We apologize for any inconvenience this may have caused you.



Best regards,



Bob

Technical Support Specialist

Microsoft Courseware Support

(e-mail address removed)



--- Original Message ---
From: (e-mail address removed)
To: (e-mail address removed)
Sent: Wed Mar 2 07:32:27 PST 2005
Subject: Microsoft.Com ContactUS


URL:http://msdn.microsoft.com/
DOM:msdnw
LANG:English (United States)
LOC:LB
BR:windows nt 5.1/mozilla/5.0 (windows; u; windows nt
5.1;/en-us,en;qSubject: Close() and Dispose() with connection pooling
Comment: This is a chaotic issue since in MSDN itself there are
contradictions. Weather SqlConnection.Dispose() returns or removes the
connections from the pool is still a debate. I have come to a conclusion
that it returns it to the pool after massive research and experimentation,
and after monitoring pooled connections in SQL server. The mistake I am
trying to report is in your book "Microsoft Official Course 2389B
Programming with Microsoft ADO.NET" module 2, p 18: "Calling the Dispose
method removes the conneciton from the connection pool". The thing is if we
cannot trust your books then what good is your documentation anyway, and why
should I pay your partners for training. I hope I recieve an answer on the
issue...
Site Bugs: in the book







From: Microsoft Learning Contact Us <[email protected]>
To: (e-mail address removed)
Date: Fri, 4 Mar 2005 20:30:18 -0800
Subject: RE:CST187877936ID - RE:Microsoft.Com ContactUS

Hello,

Your e-mail has been escalated to the next tier of support.

A representative will follow up with you directly.

Thank you again for bearing with us while we work to resolve
your issue. Please let us know if you have other concerns.

Sincerely,

Grace
Microsoft Learning Customer Support

--- Original Message ---
From: (e-mail address removed)
To: (e-mail address removed)
Sent: Thu Mar 3 18:38:19 PST 2005
Subject: CST187877936ID - RE:Microsoft.Com ContactUS


Hello,

This is Grace of Microsoft Learning Customer Support. Your e-mail has been
transferred to us for proper handling
of your issue and we're truly sorry for not responding sooner with your
concern

I understand that you're reporting a documentation on the book "Microsoft
Official Course 2389B Programming with
Microsoft ADO.NET" module 2, page 18. We apologize for the inconvenience
this may have caused you.

I am currently working with my colleagues to investigate this issue. As soon
as one of my resources replies, I will
forward the information to you.

Thank you for bearing with us while we work to resolve your issue. If you
require other assistance, please do not
hesitate to write back.

Sincerely,

Grace
Microsoft Learning Customer Support



From: icer88881 <[email protected]>
Reply-To: icer88881 <[email protected]>
To: Microsoft Learning Contact Us <[email protected]>
Date: Sat, 5 Mar 2005 09:52:32 +0200
Subject: Re: CST187877936ID - RE:Microsoft.Com ContactUS

Hello Sir, and thank you for the reply.
Your reply only adds confusion to my list of blurr facts in .NET
documentation. You stated "An internal process periodically examines
each pool and destroys unused resources.", and then you stated: "When
a SqlConnection object is disposed the underlying connection to the
database is still kept in the connection pool...", to me I sencerly
think the 2 statements without any further explanation kind of
contradict, since first you are saying that the connection is
eventually removed from the pool and in the second you say that it
stays...???
My other concern is that, you stated: "It is the Trainer's
responsibility to download these documents prior to delivery of a
course and share the information with their students."
So what if the trainer did not, and even after discussing the issue
with him many times he insisted on what was in the text, leaving no
chance for an honest mistake. I am currently learning at a very know
institute: "New Horizons Lebanon", they are supposed to be something
like "Gold Partners". My question is do they diserve to be so, or is
it just about who is paying Microsoft more for being a partner????
This issue is not the only one, this is just the top of the iceburg. I
truely hope for the best interest of Microsoft itself that this issue
be resolved n the proper manner, and I hope for supervision of such
institutes to be more stric _that is if there is any supervision at
all_ only if Microsoft CARES...
thanks...




Finally they tell me this:<------------



From: Microsoft Courseware Support <[email protected]>
To: (e-mail address removed)
Date: Tue, 15 Mar 2005 11:11:24 -0800
Subject: RE: RE:RE: CST187877936ID - RE:Microsoft.Com ContactUS




Hello Icer88881,



The development teams for Microsoft Courseware strive to make the courseware
accurate. Occasionally errors do slip into the printed manuals. We have a
mechanism for providing error updates to our certified trainers so that they
may pass corrections on to the student in the course. We have noted the
error that has caused you distress and will make sure that the replacement
for 2389B on Visual Studio 2005 does not have this error in it. We
appreciate and encourage you to report such errors to us.



On their own, the corrections previously provided do appear to be
contradictory, but if considered within the context of where they are
presented in the module, there are no contradictions. Please review the
courseware materials in their entirety while keeping in mind the corrections
previously provided. If you continue to have questions or concerns
regarding this information, we would recommend that you discuss this with
your Trainer or seek peer support through newsgroups such as
news://msnews.microsoft.com/microsoft.public.dotnet.xml or
news://msnews.microsoft.com/microsoft.public.dotnet.framework.adonet.


Best regards,



Bob

Technical Support Specialist

Microsoft Courseware Support

(e-mail address removed)


--- Original Message ---
From: (e-mail address removed)
To: (e-mail address removed)
Sent: Sat Mar 5 00:00:51 PST 2005
Subject: Re: CST187877936ID - RE:Microsoft.Com ContactUS

Hello Sir, and thank you for the reply.
Your reply only adds confusion to my list of blurr facts in .NET
documentation. You stated "An internal process periodically examines
each pool and destroys unused resources.", and then you stated: "When
a SqlConnection object is disposed the underlying connection to the
database is still kept in the connection pool...", to me I sencerly
think the 2 statements without any further explanation kind of
contradict, since first you are saying that the connection is
eventually removed from the pool and in the second you say that it
stays...???
My other concern is that, you stated: "It is the Trainer's
responsibility to download these documents prior to delivery of a
course and share the information with their students."
So what if the trainer did not, and even after discussing the issue
with him many times he insisted on what was in the text, leaving no
chance for an honest mistake. I am currently learning at a very know
institute: "New Horizons Lebanon", they are supposed to be something
like "Gold Partners". My question is do they diserve to be so, or is
it just about who is paying Microsoft more for being a partner????
This issue is not the only one, this is just the top of the iceburg. I
truely hope for the best interest of Microsoft itself that this issue
be resolved n the proper manner, and I hope for supervision of such
institutes to be more stric _that is if there is any supervision at
all_ only if Microsoft CARES...
thanks...

--- Original Message ---
From: (e-mail address removed)
To: (e-mail address removed)
Sent: Wed Mar 2 07:32:27 PST 2005
Subject: Microsoft.Com ContactUS


URL:http://msdn.microsoft.com/
DOM:msdnw
LANG:English (United States)
LOC:LB
BR:windows nt 5.1/mozilla/5.0 (windows; u; windows nt
5.1;/en-us,en;qSubject: Close() and Dispose() with connection pooling
Comment: This is a chaotic issue since in MSDN itself there are
contradictions. Weather SqlConnection.Dispose() returns or removes the
connections from the pool is still a debate. I have come to a conclusion
that it returns it to the pool after massive research and
experimentation, and after monitoring pooled connections in SQL server.
The mistake I am trying to report is in your book "Microsoft Official
Course 2389B Programming with Microsoft ADO.NET" module 2, p 18:
"Calling the Dispose method removes the conneciton from the connection
pool". The thing is if we cannot trust your books then what good is your
documentation anyway, and why should I pay your partners for training. I
hope I recieve an answer on the issue...
Site Bugs: in the book
 
W

William \(Bill\) Vaughn

This doc bug was reported years ago and fixed AFAIK--however, once it's
printed, it's hard to go out to each page and fix it. I mentioned the issue
in my ADO.NET book as well. It's been discussed here many times.

In ADO.NET 1.0 and 1.1 there is no way short of stopping your application to
manually clear the connection pool. ADO.NET 2.0 supports this functionality.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
S

Scott M.

But, you can keep your connection from using Connection Pooling in the first
place. By adding "OLEDBServices=-4" to the connection string (OLEDB
connections), the connection won't use the pool. For SQL Server add:
"Pooling=False".
 
M

M SD

Hi there, I am the guy who started this question or thread. I am not
sure weather the reply should be here or not _take me for a noob if u
want_ but here goes:
thanx first for the quick interest and reply. It fills me with sorrow to
know that this is an old issue, and that many don't know abt it, and not
that I like to make a deal out of nothing but just to know: What about
the contradiction that I mentioned about Microsoft's reply? I mean the
part where they say that the connection is marked for removal in order
for another internal process to come and remove the connection from the
pool? Can u state the facts clearly for me to know what they are, and if
it is easier point me somewhere to read a clear explanation on this _
I've been to many threads and weblogs.
Thanks again...
 
P

Pablo Castro [MS]

Sorry this mistake in the documentation caused this confusion.

Close and Dispose will both do roughly the same. For pooled connections both
will return the connection the pool. For non-pooled connections both will
close the physical connection.

I hope this helps clarify things. If it doesn't please reply to this thread
and I'll reply with further details.

--
Pablo Castro
Program Manager - ADO.NET Team
Microsoft Corp.

This posting is provided "AS IS" with no warranties, and confers no rights.
 
M

M SD

thanks Pablo, I came to the same conclusion after monitoring SQL server
pooling using performance monitors. That conclusion was contradicted by
Microsoft's attempt to clarify things for me, if you read the post you
will notice that when MS replied they told me that they corrected this
issue in 2 places but in one place they still contradict the other as I
noticed so what I need is an explanation on why this contradiction is
still in the correction itself
 

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