Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > use of MySQLConnection.dispose and/or MySQLCommand.dispose

Reply
Thread Tools

use of MySQLConnection.dispose and/or MySQLCommand.dispose

 
 
Antonio Concepcion
Guest
Posts: n/a
 
      02-17-2005
Hi!
After you close the SQL Connection using

MySQLConnection.Close

Do you still need to do a dispose as in:

MySQLConnection.Dispose
and also
MySQLCommand.Dispose?

Is this good practice?

Thanks
Antonio Concepcion





 
Reply With Quote
 
 
 
 
Tod Birdsall
Guest
Posts: n/a
 
      02-17-2005
Hi Antonio,

If you view the SqlConnection Dispose() method using a disassembler (I
use .NET Reflector) you will see that all it does is check to see if
the ConnectionState is open and if it is, it calls the Close() method.

So, to answer your question, if you call Close() yourself, there is no
need to call the Dispose() method.

Tod Birdsall, MCP
http://tod1d.blogspot.com

 
Reply With Quote
 
 
 
 
Alvin Bruney [MVP]
Guest
Posts: n/a
 
      02-17-2005
Well, there really is more to it than that. By default, the connection
pooling is on. The default behavior of close flags the connection object as
reusable and returns it to the connection pool. After 60 seconds (default
timeout), the connection is truly closed. A closed connection may then have
the managed memory reclaimed. So either call has the same effect underneath
as rightly pointed out.

--
Regards,
Alvin Bruney [Microsoft MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://www.lulu.com/owc
----------------------------------------------------------


"Tod Birdsall" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Hi Antonio,
>
> If you view the SqlConnection Dispose() method using a disassembler (I
> use .NET Reflector) you will see that all it does is check to see if
> the ConnectionState is open and if it is, it calls the Close() method.
>
> So, to answer your question, if you call Close() yourself, there is no
> need to call the Dispose() method.
>
> Tod Birdsall, MCP
> http://tod1d.blogspot.com
>



 
Reply With Quote
 
Antonio Concepcion
Guest
Posts: n/a
 
      02-17-2005
Thank you both!
So executing CLOSE on an SQLConnection is
sufficient. No further need for a DISPOSE.
Antonio

"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:%(E-Mail Removed)...
> Well, there really is more to it than that. By default, the connection
> pooling is on. The default behavior of close flags the connection object
> as reusable and returns it to the connection pool. After 60 seconds
> (default timeout), the connection is truly closed. A closed connection may
> then have the managed memory reclaimed. So either call has the same effect
> underneath as rightly pointed out.
>
> --
> Regards,
> Alvin Bruney [Microsoft MVP ASP.NET]
>
> [Shameless Author plug]
> The Microsoft Office Web Components Black Book with .NET
> Now Available @ http://www.lulu.com/owc
> ----------------------------------------------------------
>
>
> "Tod Birdsall" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) oups.com...
>> Hi Antonio,
>>
>> If you view the SqlConnection Dispose() method using a disassembler (I
>> use .NET Reflector) you will see that all it does is check to see if
>> the ConnectionState is open and if it is, it calls the Close() method.
>>
>> So, to answer your question, if you call Close() yourself, there is no
>> need to call the Dispose() method.
>>
>> Tod Birdsall, MCP
>> http://tod1d.blogspot.com
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Could not use ''; file already in use. M K ASP .Net 11 04-09-2008 11:35 AM
where to use CPLD & where to use FPGA? kulkarku@math.net VHDL 6 03-06-2006 07:27 AM
How do I know when to use the Viewstate and when to use the posted data? :-) Simon ASP .Net 1 11-09-2004 02:32 AM
Can I use XPath or something to a remote Mac or Linux box and just query an xml file, not using web services and use encyrption? jake ASP .Net 0 07-06-2004 02:16 PM
Cannot use the profile "default" because it is in use, not. please.post@yur.re.ply Firefox 1 07-04-2004 03:41 AM



Advertisments