views:

502

answers:

3

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

            }
        }
  1. Is MS-DTC a default service on Windows systems(XP, Vista, Windows 7, Servers etc)?
  2. If it is not enabled, how can I make sure it gets enabled during the installation process of my application?
+5  A: 

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.

Tuzo
A: 

This might be helpful:

http://www.thereforesystems.com/turn-on-msdtc-windows-7/

A: 

If your DBMS is SQL Server 2000 and you use a TransactionScope a distributed transaction is created even for local Transaction. However SQL Server 2005 (and probably SQL Server 2008) are smart enough to figure out that a distributed Transaction is not needed. I don't know if that only applies to local DB's or even is true if you Transaction only involves a single DB even if it's on a remove server. http://davidhayden.com/blog/dave/archive/2005/12/09/2615.aspx

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

http://subsonicproject.com/docs/BatchQuery

BatchQuery, QueueForTransaction and ExecuteTransaction will not use a TransactionScope (of course that depends on the provider implementation) but choose the transaction mechanismn of the underlying data provider (SqlTransaction in this case) which won't require MSTDC.

SchlaWiener