PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET [simplified] Reusability of objects in MySQL Connector/NET

Reply

[simplified] Reusability of objects in MySQL Connector/NET

 
Thread Tools Rate Thread
Old 12-02-2006, 09:01 PM   #1
Mochuelo
Guest
 
Posts: n/a
Default [simplified] Reusability of objects in MySQL Connector/NET


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.
  Reply With Quote
Old 12-02-2006, 10:00 PM   #2
=?Utf-8?B?RWx0b24gVw==?=
Guest
 
Posts: n/a
Default RE: [simplified] Reusability of objects in MySQL Connector/NET

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

"Mochuelo" wrote:

> 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.
>

  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off