C# ADO.NET – Best Practices for Saving Data in Different Databases

ado.netcdatabasetransaction

I would like to know if you guys have any best practice when dealing with transaction between different databases vendors.

For example, if you have a C# application that save customer data in two databases (one Oracle and the other Microsoft), what would you do?

Would you use OleDbTransaction? Is it possible?

Best Answer

As long as you can turn on MSDTC on all of the clients and servers that the transaction involves, MSDTC works like magic. It is about as simple as wrapping all of your calls in a transactionScope, and setting a condition for transactionScope.Complete() to be called. Definitely look into the security/performance issues this can cause in certain circumastances though. It is generally inadviseable to operate transactions over the internet, since it can increase the potential for attacks, but it works fine on an intranet.