Home All Groups Group Topic Archive Search About

Command.Close vs Command.Dispose

Author
13 Jan 2006 5:28 PM
Joe
Hello All:

Can anyone tell me what the difference is between the Close method of the
OleDbCommand object and the Dispose method of the OleDbCommand object?

TIA,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation

Author
13 Jan 2006 5:34 PM
Chris
Joe wrote:
> Hello All:
>
> Can anyone tell me what the difference is between the Close method of the
> OleDbCommand object and the Dispose method of the OleDbCommand object?
>
> TIA,

Dispose releases all the resources used by the object.  Close just
releases the underlining connection so it can be used again for
something else.

Chris
Author
13 Jan 2006 5:39 PM
Chris
Chris wrote:
Show quoteHide quote
> Joe wrote:
>
>> Hello All:
>>
>> Can anyone tell me what the difference is between the Close method of
>> the OleDbCommand object and the Dispose method of the OleDbCommand
>> object?
>>
>> TIA,
>
>
> Dispose releases all the resources used by the object.  Close just
> releases the underlining connection so it can be used again for
> something else.
>
> Chris

Um... On second though, the OleDbCommand object doesn't have a Close
method.  My comments would be correct for a OleDbDataReader object though.

Chris
Author
13 Jan 2006 5:44 PM
Joe
Thanks Chris.  My question wasn't accurate, but you answered the spirit of it
anyway.

--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


Show quoteHide quote
"Chris" wrote:

> Chris wrote:
> > Joe wrote:
> >
> >> Hello All:
> >>
> >> Can anyone tell me what the difference is between the Close method of
> >> the OleDbCommand object and the Dispose method of the OleDbCommand
> >> object?
> >>
> >> TIA,
> >
> >
> > Dispose releases all the resources used by the object.  Close just
> > releases the underlining connection so it can be used again for
> > something else.
> >
> > Chris
>
> Um... On second though, the OleDbCommand object doesn't have a Close
> method.  My comments would be correct for a OleDbDataReader object though.
>
> Chris
>
Author
13 Jan 2006 8:04 PM
m.posseth
About dispose :

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemidisposableclassdisposetopic.asp

if a object contains a shutdown feature like close    you must always
explicitly call it if you are finished with it

however if a component implements an idisposible interface you may call it
but it is not absolutely necesary as the GC wil call it for you


I use the following rule for good coding practice ,  for method level scoped
objects i never call a dispose method , however after the usage of a global
object  ( global to the class ) that implements idisposible i do call it


p.s.
calling dispose multiple times will only result in coding overhead , and a
bigger executable in the end :-)   , it does not hurt the performance as
idisposible has a boolean flag if it is / was called before on the current
object

regards

Michel Posseth [MCP]




Show quoteHide quote
"Joe" <joeherro@donotspam.yahoo.com> schreef in bericht
news:9065E52C-D80E-4A4C-9460-55612F213995@microsoft.com...
> Hello All:
>
> Can anyone tell me what the difference is between the Close method of the
> OleDbCommand object and the Dispose method of the OleDbCommand object?
>
> TIA,
> --
> Joe
>
> VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
Author
14 Jan 2006 2:18 AM
Dennis
Are you saying that you have to close a form before disposing of it?  I use
form.dispose when I'm thru with the form and don't bother with the form.close
method unless I want to show the form again.  Will I have a problem doing
this?
--
Dennis in Houston


Show quoteHide quote
"m.posseth" wrote:

>
> About dispose :
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemidisposableclassdisposetopic.asp
>
> if a object contains a shutdown feature like close    you must always
> explicitly call it if you are finished with it
>
> however if a component implements an idisposible interface you may call it
> but it is not absolutely necesary as the GC wil call it for you
>
>
> I use the following rule for good coding practice ,  for method level scoped
> objects i never call a dispose method , however after the usage of a global
> object  ( global to the class ) that implements idisposible i do call it
>
>
> p.s.
> calling dispose multiple times will only result in coding overhead , and a
> bigger executable in the end :-)   , it does not hurt the performance as
> idisposible has a boolean flag if it is / was called before on the current
> object
>
> regards
>
> Michel Posseth [MCP]
>
>
>
>
> "Joe" <joeherro@donotspam.yahoo.com> schreef in bericht
> news:9065E52C-D80E-4A4C-9460-55612F213995@microsoft.com...
> > Hello All:
> >
> > Can anyone tell me what the difference is between the Close method of the
> > OleDbCommand object and the Dispose method of the OleDbCommand object?
> >
> > TIA,
> > --
> > Joe
> >
> > VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
>
>
>
Author
14 Jan 2006 7:04 AM
Cor Ligthert [MVP]
Dennis,

Just do it as Michel says, where however the modal form is on of the
exceptions which you have to dispose.

Howerver closing something end than disposing it is AFAIK stupid.

Cor