Click here to Skip to main content
15,886,069 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am making a winform application in c#. I need to update/insert or delete two different tables in two different databases on two different servers and I want to do it with transaction (If update in one database fails, the other will be rolled back.)

How can I do it, please give some code in c# and also state whether it is good to do mysql transaction over two different servers (I mean, is there any chances that database will get corrupted by poor implementation of distributed transaction as I read this in some forum).

I searched over internet but I could not find c# code.

Thank you
Posted
Comments
Mehdi Gholam 16-Jun-15 0:22am    
Why 2 different servers?

You are abusing transaction.
Member 9856173 16-Jun-15 5:11am    
Abusing transaction :) LOL, Actual I am making a point of sale system. There will be 15 branches. At each branch, there will be a local server in the local branch office. At the end of day, Users will click a button and all entries of the day will be inserted in a Database on a BIG server connected through WAN and in local DB table, entries will be deleted or flagged as posted.

Obviously, This needs to be done in transaction.

Replication is not a good option because of some other factors.

I need a C# MySQL code for XA or distributed transactions please.

1 solution

can you try distributed transaction functionality in SQL kindly go through the link m not sure up to what extend it was going to help you

https://redmondmag.com/articles/2014/02/27/sql-server-distributed-transactions.aspx[^]
 
Share this answer
 
Comments
Mehdi Gholam 16-Jun-15 7:28am    
The OP requires mysql not sql server.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900