Transactions with configured TableAdapters

S

Shimon Sim

Hi
I followed some walkthrough for creating Typed Dataset and TableAdapters.
One thing I can't figure out is how to use transactions with generated Table
Adapters.
Any ideas?
Thanks,
Shimon
 
S

Shimon Sim

Now this didn't help.
I get error MSDTC on server 'SIATA' is unavailable.
What is next?
Thank you,
Shimon
 
S

Shimon Sim

For Those interested.
My scenario is different from the example since I had to maintain
transaction through different adapters.
SO we just create new file and declare partial class. Make sure to have
correct namespace and class name.
Then I introduce following method
public void InitializeTransaction(SqlConnection connection, SqlTransaction
transaction)

{

_connection = connection;

this.Adapter.InsertCommand.Transaction = transaction;

Adapter.UpdateCommand.Transaction = transaction;

Adapter.DeleteCommand.Transaction = transaction;

foreach (SqlCommand command in CommandCollection)

{

if (command.CommandText.ToUpper().StartsWith("INSERT")) //this is for custom
queries. You mane need to have different checks here

{

command.Transaction = transaction;

}

}

}

That is it.
Now just create connection and transaction and pass it to addapter before
calling any dataaccess methods.
 

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