日期:2014-05-17  浏览次数:20777 次

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++)
                    {