Dataset dispose

  • Thread starter Thread starter Agnes
  • Start date Start date
A

Agnes

Does dataset dispose will lead the related dataadpator , or database will
dispose also ?
Or I need to dispose them one by one ??
 
Does dataset dispose will lead the related dataadpator , or database will
dispose also ?
Or I need to dispose them one by one ??

You do not need to call Dispose on a DataSet. It's one of the few
exceptions to the rule that you should call Dispose when you're
finished using an object. It is recommended that you continue calling
Dispose on connection and data adapter objects though.

And no, calling Dispose on a DataSet will not dispose anything else.
 
you don't need to call .Dispose on anythnig

if the objects don't clean up after themselves then call up M$ tech
support

THIS CRAP IS NEITHER VISUAL NOR BASIC
 
Larry Linson said:
you don't need to call .Dispose on anythnig

That's true ("need" interpreted in the sense of "it's not necessary, but it
may cause the application to refuse to work properly"), but this doesn't
mean that it doesn't make sense to prevent the application from running out
of unmanaged resources (connections, file handles, ...).

I suggest to call 'Dispose' on every object that provides the method,
because alternative implementations of the .NET Framework may place code
there to free unmanaged resources.
 
you don't need to call .Dispose on anythnig

if the objects don't clean up after themselves then call up M$ tech
support

THIS CRAP IS NEITHER VISUAL NOR BASIC

You don't *have* to call Dispose (or Close). In the case of an
IDbConnnection the GC will eventually clean it up, but until it does
you'll have a dangling connection that remains open.
 
I suggest to call 'Dispose' on every object that provides the method,

But don't do it myself.
You can look at my website you don't see any Textbox.dispose, label.dispose,
etc.Written for M S Herfried K. Wagner. I hope he likes it I did some work
for him.

Cor
 
But don't do it myself.
You can look at my website you don't see any Textbox.dispose, label.dispose,
etc.

Those are eventually called through the Control.Dispose implementation
of the containing Form.
 
Brian,

You would not believe it, I know that already some time.
But therefore Herfrieds advise is even more wrong if you know that..

Cor
 
Cor Ligthert said:
You would not believe it, I know that already some time.
But therefore Herfrieds advise is even more wrong if you know that..

Well, I should have written: "I suggest to make sure 'Dispose' is called on
every object implementing 'IDisposable' when the object is not needed any
more."
 
For sure that is a fine text in my idea completely as it has to be.

But also for by instance members from the namespace System.Data.

Where the team has taken the action to dispose if it is needed after every
close.

Cor
 
Back
Top