TransactionScope分布式事务出错:msdtc已经取消了分布式事务。该怎么解决
TransactionScope分布式事务出错:msdtc已经取消了分布式事务。
using (TransactionScope scope = new TransactionScope())
{
using (SqlBulkCopy bulkCopy = new SqlBulkCopy(Configuration.ConnectionString))
{
bulkCopy.DestinationTableName = "GeographyPerformanceData";
bulkCopy.BatchSize = geoPerformTable.Rows.Count;
bulkCopy.WriteToServer(geoPerformTable);
bulkCopy.Close();
}
//批量更新(使用了SqlTranaction事务)
if (lstUpdateSql.Count > 0)
{
int updatedCount = KPIPerformanceDataBLL.Instance.BatchUpdate(lstUpdateSql);
if (updatedCount == 0)
{
ri.Success = false;
ri.Message = "导入失败!请重试。";
return ri;
}
}
//同步地区目标数据到经理信息,在sql语句中使用了tran事务
for (int rowIndex = 0; rowIndex < performData.Rows.Count; rowIndex++)
{
geographyCode = performData.Rows[rowIndex][4].ToString().Trim();
try
{
GeographyPerformanceDataBLL.Instance.SyncGeoTargetToManager(PerformanceEvalInfo.Id, geographyCode);
}
catch (Exception ex)
{
ri.Success = false;
ri.Message = "同步地区目标数据到经理信息出错!\n内部错误说明:" + ex.Message;
return ri;
}
}