private static bool GetExecuteBacheNonQueryDo(List <BaseQuery> lsSqlCommandQuery, out Exception Ex, List <DataTable> dtList, string targetdb) { DataAccess da = DataAccessFactory.CreateSqlDataAccessWriter(dc.conn(targetdb)); Ex = null; //定义事物执行成功与否 bool isSuccess = true; //记录事务 bool bl = true; //提交事务记录 bool commit = false; //打开事务 da.Open(); using (IDbTransaction t = da.BeginTransaction()) { try { if (lsSqlCommandQuery != null && lsSqlCommandQuery.Count > 0) { foreach (BaseQuery q in lsSqlCommandQuery) { if (da.ExecuteNonQuery(q) < 0) { bl = false; break; } else { continue; } } } if (dtList != null && dtList.Count > 0 && bl) { IVdb dbculkcopy = DbProvider.GetVdb(dc.conn(targetdb).Writer.DatabaseType); dbculkcopy.TransationBulkCopy(da, da.Connection, t, dtList, bl); } if (bl) { commit = true; } else { commit = false; } if (commit == true) { isSuccess = true; t.Commit(); } else { isSuccess = false; t.Rollback(); } } catch (Exception ex) { t.Rollback(); Ex = ex; LogService.Default.Fatal("数据库事务执行失败:失败原因" + ex.Message, ex); isSuccess = false; } } da.Close(); return(isSuccess); }