Command Objects

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Typically, I create a command object and execute it and then if I want to
execute additional SQL I create another command object to do this. Is this
correct or can/should I re-use the existing command object? If it is
appropriate to create another command object, do I need to use the Dispose()
method on the command object or is this unnecessary?

Thanks in advance for your assistance!
 
I've read its cheaper to "start over" then to tear down and rebuild up a
command object.

You don't need to call the Dispose method.

...

Or better check out either
Data Access Application Block 2.0 (sql server specific)
or
EnterpriseLibrary.Data

Google it and you'll find a bunch of hits.

The "blocks" handle alot/most of the best practices for you.
 
Hi,

| Typically, I create a command object and execute it and then if I want to
| execute additional SQL I create another command object to do this. Is
this
| correct or can/should I re-use the existing command object? If it is
| appropriate to create another command object, do I need to use the
Dispose()
| method on the command object or is this unnecessary?
|
| Thanks in advance for your assistance!

If you are going to create a completely different command then just create
it again.
If you are gouing to execute the same command changing only the values of
the parameters reuse the same command.
 
Back
Top