[simplified] Reusability of objects in MySQL Connector/NET

M

Mochuelo

Hi,

My previous post may be too confusing. This is the idea of my doubt:

To do one single SELECT-type query, or one single INSERT-type query, I
have no problems.

To do multiple queries in a row, which objects can I reuse? Do I need
to instantiate a new connection (MySqlConnection) object, a new
command (MySqlCommand) object, and a new data reader (MySqlDataReader)
object for each and every query? I guess this would work, but would it
would be optimum in terms of time and resources? I tend to think it
would not.

Can I at least reuse the connections? I hope the answer to this is
"yes".

Can I reuse an instance of MySqlCommand in two queries in a row? This
is where my serious doubts start.

Can I reuse an instance of MySqlDataReader, too?


Thanks for your help.
Mochuelo.
 
G

Guest

Hi Mochuelo,

While a DataReader is open, the Connection is in use exclusively by that
DataReader. You will not be able to execute any commands for the Connection,
including creating another DataReader, until the original DataReader is
closed.

HTH

Elton Wang
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top