-1

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."


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();
        }

    }
Mitch Wheat
  • 295,962
  • 43
  • 465
  • 541
Partha
  • 2,062
  • 6
  • 24
  • 31

1 Answers1

3

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#

Community
  • 1
  • 1
Mitch Wheat
  • 295,962
  • 43
  • 465
  • 541
  • 1
    Thanks Mitch Wheat, After set firewall to off. It is works. Thanks Lot – Partha Apr 28 '09 at 07:10
  • 1
    @Sarathis1904 If Mitch's answer fixed it then do mark it as the answer and upvote. – Fung Apr 28 '09 at 07:17
  • @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 Apr 28 '09 at 07:28