Network Access Disabled for Distributed Transaction Manager (MSDTC)

Error:

Network Access for Distributed Transaction Manager (MSDTC) is disabled. Enable DTC to access the network in the security configuration for MSDTC using the component services administration tool.

using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope()) 11 { 12 try 13 { 14 foreach (DataRow row in this.dt1.Rows) 15 { 16 int titleId = int.Parse(row["titleId"].ToString()); 17 string fname = row["fname"].ToString(); 18 string lname = row["lname"].ToString(); 19 20 if (cmd.Parameters.Count > 0) 21 cmd.Parameters.Clear(); 22 23 cmd.Parameters.AddWithValue("@titleId", titleId); 24 cmd.Parameters.AddWithValue("@fname", fname); 25 cmd.Parameters.AddWithValue("@lname", lname); 26 cmd.ExecuteNonQuery(); 27 28 } 29 con.Close(); 30 ts.Complete(); 31 } 32 catch (Exception ex) 33 { 34 35 } 36 } 37 } 
+6
source share
2 answers

To enable network access to MSDTC on Windows Vista / 7/8 Server 2008R2 / 2012 , follow these steps:

  • Click Start , click Run , enter dcomcnfg and click OK to open Component Services .

  • In the console tree, expand Component Services , click to expand Computers , click to expand My Computer , click to expand Distributed Transaction Coordinator , and then click Local DTC .

  • Right-click Local DTC and click Properties to display the Local DTC Properties dialog box.

  • Click the Security tab.

  • Check the box next to "Access DTC Access Network .

  • Select the Allow Inbox and Allow Outbox checkboxes.

  • Click Apply , OK .

  • A message about restarting the service appears .

  • Click OK and that’s it.

+18
source share

Close the connection after the transaction is completed. The full method.

 ts.Complete(); con.Close(); 

completed code

 using (System.Transactions.TransactionScope ts = new Sytem.Transactions.TransactionScope()) { try { foreach (DataRow row in this.dt1.Rows) { int titleId = int.Parse(row["titleId"].ToString()); string fname = row["fname"].ToString(); string lname = row["lname"].ToString(); if (cmd.Parameters.Count > 0) cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@titleId", titleId); cmd.Parameters.AddWithValue("@fname", fname); cmd.Parameters.AddWithValue("@lname", lname); cmd.ExecuteNonQuery(); } ts.Complete(); con.Close(); } catch (Exception ex) { } } 
+1
source share

All Articles