> In most data providers, Connection.Dispose simply calls
> Connection.Close, and, in case of SqlClient, NULLs out the
> connection string so you can't use the Connection again
> without replacing it. In most providers, Command.Dispose is
> not strictly required, but, in at least one case, (OleDb data
> provider + MSDAORA OLE DB provider), Command.Dispose releases
> any internal database cursors, so if you don't call it, you

I would assume that would also mean that the command would have to be
disposed before the connection?
If the order was required, I'm wondering why the Connection's dispose
doesn't also call the selectcomments(,etc) dispose methods

> will indeed run out of cursors. There is at least one ADO.NET
> book out that discusses this. ;-)

heh..pray tell :-)
I'm guessing from your emoticon that it's one of yours <bg>


> Database programmers are used to calling Close; Dispose is
> .NET convention, so, for the Connection both are provided.
> Command.Dispose is not used by all provider writers, but can
> be used to clean up, because, for instance, there is a
> Command.Prepare method but no Command.Unprepare.
> IDbConnection and IDbCommand both inherit from IDisposable,
> therefore a Dispose method must be coded, even if it is only
> a no-op (or delegates to Close).

But it would be best to still call the Dispose methods just so if changes to
the provider you're using needs to do something like the Oracle one and
requires a Dispose

Fair enough

Thanks :-)

Merak
(and btw..subbing to other lists now <g>)

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to