473,466 Members | 1,370 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Command.Close vs Command.Dispose

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
Jan 13 '06 #1
6 18459
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
Jan 13 '06 #2
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
Jan 13 '06 #3
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
"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

Jan 13 '06 #4

About dispose :

http://msdn.microsoft.com/library/de...sposetopic.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" <jo******@donotspam.yahoo.com> schreef in bericht
news:90**********************************@microsof t.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

Jan 13 '06 #5
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
"m.posseth" wrote:

About dispose :

http://msdn.microsoft.com/library/de...sposetopic.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" <jo******@donotspam.yahoo.com> schreef in bericht
news:90**********************************@microsof t.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


Jan 14 '06 #6
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
Jan 14 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tim Bücker | last post by:
I´ve got a little program with the "x" in the upper right corner and a menu item "close" to do the same - end the program. The problem now is that using my program it gets sometimes impossible to...
11
by: Pablo Salazar | last post by:
Hi people!!. Which is diference between to use method CLOSE and DISPOSE to close a form? Tx. Pablo Salazar
1
by: Daniel | last post by:
If my System.IO.StreamWriter Write method throws "The specified network name is no longer available." and I try to Dispose or Close it in the finaly clause the close or dispose method just throws...
19
by: Nathan | last post by:
I know this has been asked previously, but I've run into a situation where I need to know the difference between close and dispose, and I can't get the information I need from msdn help or previous...
5
by: jobs | last post by:
re: try catch finally to close and dispose, but still want Application_error to fire 1. If catch an exception to to dispose and close of a ado connect, how can I allow the exception to still...
4
by: enggwaqas | last post by:
I have an Oracle stored procedure that takes approx 3 minutes to execute and I am using .net 2.0 data access provider for oracle. Now i want to cancel the execution of stored procedure from .net...
18
by: Eric B. | last post by:
Is it a bad idea to do both once I'm done with an object? Eric B.
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.