N
Niall
I'm trying out the new TableAdapters in ADO.Net 2.0. I was a bit surprised
to see control of transactions being somewhat taken away from me and placed
into the System.Transactions namespace. I had a read and saw all the stuff
about distributed transactions, which seems quite cool for managing access
to multiple resources of different types. However, for plain old SQL
Transactions, it seems like if you're not careful, you might end up paying a
performance hit.
So I wrote a small app that inserts rows in a few tables in one function.
This all needs to be inside the one transaction. So I use the
TransactionScope, and everything seemed sweet while I was only posting the
first TableAdapter. Once I started posted the other two, I received
exceptions complaining that the MSDTC was not running. After reading the
generated code for the TableAdapters, it appears that what I have to do is
ensure that the first adapter's connection is open before it posts
(otherwise it will close it again), and that the other adapters all have
their connections assigned to be the first adapter's connection. This seems
to leave SQLServer 2005 happy enough to do it all on one transaction and not
involve the MSDTC.
Is this the "proper" way to get around your transaction getting promoted up
to the MSDTC? Also, can I/should I close the SqlConnection I manually opened
before/after completing the TransactionScope, or should I leave it?
Niall
to see control of transactions being somewhat taken away from me and placed
into the System.Transactions namespace. I had a read and saw all the stuff
about distributed transactions, which seems quite cool for managing access
to multiple resources of different types. However, for plain old SQL
Transactions, it seems like if you're not careful, you might end up paying a
performance hit.
So I wrote a small app that inserts rows in a few tables in one function.
This all needs to be inside the one transaction. So I use the
TransactionScope, and everything seemed sweet while I was only posting the
first TableAdapter. Once I started posted the other two, I received
exceptions complaining that the MSDTC was not running. After reading the
generated code for the TableAdapters, it appears that what I have to do is
ensure that the first adapter's connection is open before it posts
(otherwise it will close it again), and that the other adapters all have
their connections assigned to be the first adapter's connection. This seems
to leave SQLServer 2005 happy enough to do it all on one transaction and not
involve the MSDTC.
Is this the "proper" way to get around your transaction getting promoted up
to the MSDTC? Also, can I/should I close the SqlConnection I manually opened
before/after completing the TransactionScope, or should I leave it?
Niall