tags:

views:

251

answers:

3

I am trying make a database transaction(inserting records) across multiple system. So, I decided to use System.Transaction Namespace in .net. I configured MSDTC on both system(But i dont know whether i configured correctly). My transaction has two insert query one will execute at local system. another, will execute at some other system in a local network. First insert query work successfully but second one raise a error like : Message = "The transaction has already been implicitly or explicitly committed or aborted."

Please help in this case to over come.

+2  A: 

First check that the DTC is actually running (on local and remote system), and then try setting both DTC's authentication to 'anonymous' to see if it's a permissions problem.

Also, check the firewall settings on remote and local machine.

Check out this FAQ: Distributed Transaction Coordinator(MSDTC) and Transaction FAQ

Configuring MS DTC Services

Related to this SO question: HRESULT: 0x8004D00E using TransactionScope - C#

Mitch Wheat
Thanks, I will do that
Sarathi1904
Thanks Mitch Wheat, After set firewall to off. It is works. Thanks Lot
Sarathi1904
@Sarathis1904 If Mitch's answer fixed it then do mark it as the answer and upvote.
fung
@Sarathis1904: setting firewall to off has verified it, but please don't leave it turned off! See the link above: Enable Firewall Exceptions for MS DTC
Mitch Wheat
@Sarathis1904: just wondering if you were going to accept this answer?
Mitch Wheat
A: 

Where i can find this option. please.

Sarathi1904
A: 

Here is my Code

    using (TransactionScope txSc = new TransactionScope())
    {
        //vrm = new VolatileRM();
        //vrm.SetMemberValue(3);
        try
        {
            using (SqlConnection cn = new SqlConnection(connStr1))
            {
                SqlCommand cmd = cn.CreateCommand();
                cmd.CommandText = "Insert into empdetail Values ('YYY')";
                cn.Open();
                cmd.ExecuteNonQuery();
                cn.Close();
            }
            using (SqlConnection cn = new SqlConnection(connStr))
            {
                SqlCommand cmd = cn.CreateCommand();
                cmd.CommandText = "Insert into stu Values ('23','senthil')";
                cn.Open();
                cmd.ExecuteNonQuery();
                cn.Close();
            }                    
            txSc.Complete();
        }
        catch (Exception e)
        {
            txSc.Dispose();
        }

    }
Sarathi1904
All that confirms is that your Transaction will require a DTC given that the two connection strings are different...
Mitch Wheat
BTW, you don't need the txSc.Dispose(); call as the using block disposes for you.
Mitch Wheat
@Sarathi1904: please add code and any extra information to the question rather than posting it as answers. Thanks.
Mitch Wheat