Understanding MSDTC on Windows

To use the transactional construct (as described below) in Subsonic, MSDTC must be running on a Windows machine. Right?

using (TransactionScope ts = new TransactionScope()) { using (SharedDbConnectionScope sharedConnectionScope = new SharedDbConnectionScope()) { // update table 1 // update table 2 // ts.commit here } } 
  • Is MS-DTC the default service on Windows systems (XP, Vista, Windows 7, Servers, etc.)?
  • If it is not turned on, how can I make sure that it is turned on during the installation process of my application?
+4
source share
4 answers

MSDTC must be installed with windows. If it cannot be installed using the following command:

 msdtc -install 

You can configure the MSDTC service with sc.exe. Install the service to automatically start and start the service:

 sc config msdtc start= auto sc start msdtc 

Please note that to complete the above, you will need administrator privileges.

+7
source

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; } 
+2
source

If your DBMS is SQL Server 2000 and you use TransactionScope, a distributed transaction is created even for a local transaction. However, SQL Server 2005 (and probably SQL Server 2008) is smart enough to realize that a distributed transaction is not needed. I do not know if this applies only to the local database, or even true if you use a transaction with only one database, even if it is located on a remote server. http://davidhayden.com/blog/dave/archive/2005/12/09/2615.aspx

One hint, you can use a batch request to avoid TransactionScope.

http://subsonicproject.com/docs/BatchQuery

BatchQuery, QueueForTransaction, and ExecuteTransaction will not use TransactionScope (of course, it depends on the provider implementation), but select the transaction mechanism of the main data provider (SqlTransaction in this case), which does not require MSTDC.

0
source

All Articles