SqlTransaction to support multiple SqlConnections

So, I have several SqlConnections that I want all of them to be used in one SqlTransaction . I know that I can use only one connection, but in the end, each connection has many new and useless (after connecting) variables, and I need the program to remain as fast as possible.

I have every connection in a using statement.

I am using the latest .NET and SQL Server 2008 R2.

Is it possible?

ALSO, I already looked:

How to use one SqlTransaction for several SqlConnections in .NET?

No one answered the question, the platforms are out of date.

+4
source share
1 answer

You have an answer that I will give you, TransactionScope.

The goal of this is to automatically join your connections to an existing transaction.

 using(System.Transacation.TransactionScope myScope = new TransactionScope()){ //all of your sql connections and work in here //call this to commit, else everything will rollback myScope.Complete(); } 

Take a look at the transaction here:

http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx

If this does not answer your question, I did not fully understand it.

+11
source

All Articles