0

How can I use an ADO.NET Manual Transaction to remove records across two databases (on same server)?

I came across this:

TransactionScope in .NET 1.1

But would still like to use .NET 1.1 Manual Transaction if possible.

IrishChieftain
  • 15,108
  • 7
  • 50
  • 91
  • 2
    DId you copy all the code? There is clearly a Dispose() implementation in that class. – Joe Feb 27 '12 at 21:03
  • Well spotted Joe (+1), I'll go ahead and code the rest of it. In the meantime, is it definitely not possible to manage the transaction as in first snippet here? http://msdn.microsoft.com/en-us/library/ms973865.aspx – IrishChieftain Feb 27 '12 at 21:16
  • 2
    ASP.NET 1.1 -> wow, don't know why, but in 2012 that sounds even worse than COM to me :-) I really don't get it. Who are the persons responsible for taking architecture design decision in companies? What kind of people are they? Do they have basic programming culture? How did they winded in such positions? – Darin Dimitrov Feb 27 '12 at 21:27
  • I won't say in case they're reading this! ;-) – IrishChieftain Feb 27 '12 at 21:33
  • @DarinDimitrov: it happens. We had 1.1 code at my old job; imagine a team of ~10 devs and about 45 systems. It was not practical to upgrade them all to the latest .NET, regression test them, etc. – Joe Feb 27 '12 at 21:45
  • @Joe, of course that it's practical. Just set .NET version in IIS to 4.0 and write proper code. Believe me, the time you're gonna spend maintaining legacy crap will be far greater than the time to do a regress test all your existing applications. – Darin Dimitrov Feb 27 '12 at 21:47

1 Answers1

1

Wow, been a while since I've looked at 1.1. An ado.net transaction is associated with a connection so there's not really a good way to do this in 1 manual transaction. I remember writing my own cross database txn management class where an executing command would basically register with it and I would keep track of the txns myself. Kind of my own TransactionScope or unit of work. I would roll back all of them if something erred or commit all of them at the end if a "complete" method was called.

The method in the article seems better other than it will invoke DTC (which is ok as long as you want that). I don't think there's a better way to do this.

swannee
  • 3,346
  • 2
  • 24
  • 40
  • What are the implications of it invoking the DTC, if any? – IrishChieftain Feb 27 '12 at 21:56
  • Well, just that you have DTC set up and properly configured on the machine(s), which isn't a huge deal but has been known to give some people fits on large installations, and it's one more thing to configure etc... Frankly, I don't know the how much performance overhead is allocated by MSDTC, but it is an external service that is coordinating your transactions and is meant to coordinate enterprise distributed transactions so if you just have two databases on the same server that need coordination, it's probably driving a nail with a pile driver. – swannee Feb 27 '12 at 22:40