To use transaction construct(as follows) in Subsonic, MSDTC needs to be running on Windows machine. Right?
using (TransactionScope ts = new TransactionScope())
{
using (SharedDbConnectionScope sharedConnectionScope = new SharedDbConnectionScope())
{
// update table 1
// update table 2
// ts.commit here
}
}
MSDTC should come installed with windows. If it's not it can be installed with the following command:
msdtc -install
You can configure the MSDTC service using sc.exe. Set the service to start automatically and start the service:
sc config msdtc start= auto
sc start msdtc
Note you will need administrator privilege to perform the above.
I use:
private bool InitMsdtc()
{
System.ServiceProcess.ServiceController control = new System.ServiceProcess.ServiceController("MSDTC");
if (control.Status == System.ServiceProcess.ServiceControllerStatus.Stopped)
control.Start();
else if (control.Status == System.ServiceProcess.ServiceControllerStatus.Paused)
control.Continue();
return true;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With