Re: Using existing connection and transaction with QueriesTableAdapter queries
Posted by: Matt Benic
Date: January 06, 2010 08:00AM

I just noticed that the QueriesTableAdapter class is partial, so in my case the following does the job nicely:

namespace ImportLocalizationData.dsImportTableAdapters
{
// Helper function added to QueriesTableAdapter to allow us to use our connection and transaction
public partial class QueriesTableAdapter : ComponentModel.Component {
public void SetConnectionAndTransaction(MySqlConnection connection, MySqlTransaction transaction)
{
foreach (IDbCommand command in this.CommandCollection)
{
command.Connection = connection;
command.Transaction = transaction;
}
}
}
}

Of course care needs to be taken not to reuse the object in a context with different connection and transaction needs, but the same would be true of any TableAdapter object. I can see this being quite inefficient in cases with a large number of queries in the QueryTableAdapter, so a way to specify an initial connection and transaction to be used would be very helpful.

Options: ReplyQuote


Subject
Written By
Posted
Re: Using existing connection and transaction with QueriesTableAdapter queries
January 06, 2010 08:00AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.