I have 2 servers (one for applications and another for database) with Windows Server 2008 R2
and SQL Server 2008 R2
.
I have installed an application developed with C # .NET Framework 2.0 and 2 Databases, I use TransactionScope
to manage Insert
, Update
, Delete
, if I execute these operations in a single Base of Data everything finishes perfect but if I execute these two operations in the 2 databases I start having problems with TransactionScope
.
This conflict does not occur if I install my application on the same server as the Database. I have already executed a MSDTC
configuration on both servers but I can not solve my problem, I have the Firewall active, I do not know if this also causes conflict.
Next I add an example of the code that I use for my operations to BD, this code I have it in a method called Executing Sale of the VentaManager class:
using (TransactionScope scope = new TransactionScope())
{
//El objeto ventasPorUnidadBD ejecuta un insert en la Base de datos "A"
ventasPorUnidadBD.Insert(objVentas);
//El objeto inventarioBD ejecuta un update en la Base de datos "A"
inventarioBD.UpdateInventario(objVentas);
//El objeto solicitudVentaBD ejecuta un update en la Base de datos "A"
solicitudVentaBD.Delete(objSolicitudVenta);
//El objeto movimientoPorMesBD ejecuta un update en la Base de datos "B"
movimientoPorMesBD.Insert(objVentas);
//El objeto bitacoraSistemaBD ejecuta un update en la Base de datos "B"
bitacoraSistemaBD.Insert(objBitacora);
//Hacer Commit a la transacción
scope.Complete();
}
When the exception is executed, the next record is generated in my log file:
(06/13/2017 08:03:37 p.m.) MovementPerMesBD.Insert (); - The transaction has already been implicitly or explicitly committed or aborted.
(06/13/2017 08:03:37 p.m.) SaleManager.EjecutaVenta (); - Object reference not set to an instance of an object.
I hope you can help me with this problem.
Thanks and regards.