Skip to content
Advertisement

How to use a single SqlTransaction for multiple SqlConnections in .NET?

  1. I have SQL Server 2000, it doesn’t support MultipleActiveResults.
  2. I have to do multiple inserts, and it’s done with one connection per insertion.
  3. I want to begin a transaction before all insertions and finish it after all insertions.
  4. How do I do it?

Advertisement

Answer

What is the reason you don’t use one connection and multiple commands (actually one command recreated in loop)? Maybe this solution will work for you:

Also see
Sql Server Transactions – ADO.NET 2.0 – Commit and Rollback – Using Statement – IDisposable

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement