在某些机器上,TransactionScope自动升级到MSDTC?
using (TransactionScope transactionScope = new TransactionScope() { using (SqlConnection connection = new SqlConnection(_ConStr)) { using (SqlCommand command = connection.CreateCommand()) { // prep the command connection.Open(); using (SqlDataReader reader = command.ExecuteReader()) { // use the reader connection.Close(); } } } // Do other stuff here that may or may not involve enlisting // in the ambient transaction using (SqlConnection connection = new SqlConnection(_ConStr)) { using (SqlCommand command = connection.CreateCommand()) { // prep the command connection.Open(); // Throws "MSDTC on [SERVER] is unavailable" on some... // gets here on only half of the developer machines. } connection.Close(); } transactionScope.Complete();}
不负相思意
相关分类