I have a web server and two database servers on two different networks: Db1 and Db2 (remote database).
- DB1: SQL Server 2008 R2, Operating System: Windows Server 2003 SP2
- DB2: SQL Server 2000, operating system: Windows Server 2003 R2
- Web Server: Windows Server 2003 R2
I want to insert two different records into these databases, and I use TransactionScope .
using (TransactionScope tscope = new TransactionScope(TransactionScopeOption.RequiresNew)) {
When I trace the source code, inserting into the first database is successful, but when the second connection wants to be open, I encounter the error below.
Error:
The deal has already been implicitly or explicitly committed or interrupted.
I set up MSDTC, the Distributrd Transaction Coordinator, and everything is fine. I can distribute transactions on my database server and I have no problem. What happened to TransactionScope ? Please help me.
the first connection is LINQ TO SQL:
DataClassesDataContext Dac = new DataClassesDataContext(); Dac.Connection.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionCs"].ConnectionString; tbl_KargahDistribution Workshop = new tbl_KargahDistribution(); Workshop.WpCode = Bodu.WpRealCode; Workshop.State = Bodu.BduState; Workshop.City = Bodu.BduCity; Workshop.Town = Bodu.BduTown; Workshop.SubSystem = Bodu.BduSubSystem; Dac.tbl_KargahDistributions.InsertOnSubmit(Workshop); Dac.SubmitChanges();
second connection:
Queries Qu = new Queries(); SqlCon = new SqlConnection(BoBaz.BazConnectionString); SqlCon.Open(); string sq = Qu.InsertWorkshopBaseInfo(); SqlCom = new SqlCommand(sq, SqlCon);
source share