473,385 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Command Objects

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!
Feb 7 '07 #1
2 2989

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.

"JimHeavey" <Ji*******@discussions.microsoft.comwrote in message
news:A9**********************************@microsof t.com...
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!

Feb 7 '07 #2
Hi,

"JimHeavey" <Ji*******@discussions.microsoft.comwrote in message
news:A9**********************************@microsof t.com...
| 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.
--
Ignacio Machin
machin AT laceupsolutions com
Feb 7 '07 #3

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

Similar topics

2
by: Hans Deragon | last post by:
Greetings. I am performing: commands.getstatusoutput("rsync <params>"); rsync takes a long time and prints out a steady stream of lines showing which file it is currently working on.
4
by: Tom | last post by:
I want to open a recordset object on an .asp page. When I open the recordset I would like to use a stored procedure that expects a parameter to be passed for the stored procedure. I will then use...
7
by: Subhransu Sekhar Sahoo | last post by:
Hi, I have a very basic qus. An executable can be written using n number of languages, viz C,,C++,Perl,Java,...And all these languages use different calling convensions for example C uses cdecl...
2
by: Jacob | last post by:
A simple question: I've read a couple of things that indicates I can create a new table in my database using some SQL command. Is this correct? I would like to load a database into a DataSet,...
11
by: Andrew Warren | last post by:
When I build my winforms exe using the IDE I have a perfectly functioning exe. If I try to build the same project using the .Net Framework csc compiler I get a seemingly valid exe produced...
1
by: Tiago Costa | last post by:
I want to call a OSQL command to BackUp my data base, how can i call it from Visual Studio (C#) 2003. Thanks In Advance, Tiago Costa
3
by: Samuel R. Neff | last post by:
We're working on implementing a Command Pattern design with our application in order to help facilitate undo/redo. This is fine four user actions we control which basically means menu actions. ...
12
by: alan | last post by:
Can VB.NET directly executing the sql command for insert, update and delete but not using data adapter.insertcomand, adapter.deletecomand, adapter.updatecomand? Just like in VB6 , I can directly...
3
by: neonk | last post by:
I create a number of Global ADO Commands on Application Load. Every 30 seconds I use these to recreate Recordsets (Most of the RS are not global, so are recreated each time instead of just being...
2
by: luanhoxung | last post by:
Hi, Folks Please show me what happen ? In my Code, I declare: cm as command the word "command" doesnot capital the first letter like : Command. And i think VBA doesnot know what is cm ?? But in...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.