System.Data.SqlClient.SqlTransaction.Rollback C# (CSharp) Method

Rollback() public method

public Rollback ( ) : void
return void
        override public void Rollback()
        {
            Exception e = null;
            Guid operationId = s_diagnosticListener.WriteTransactionRollbackBefore(_isolationLevel, _connection, null);

            if (IsYukonPartialZombie)
            {
                // Put something in the trace in case a customer has an issue
                _internalTransaction = null; // yukon zombification
            }
            else
            {
                ZombieCheck();

                SqlStatistics statistics = null;
                try
                {
                    statistics = SqlStatistics.StartTimer(Statistics);

                    _isFromAPI = true;

                    _internalTransaction.Rollback();
                }
                catch (Exception ex)
                {
                    e = ex;
                    throw;
                }
                finally
                {
                    if (e != null)
                    {
                        s_diagnosticListener.WriteTransactionRollbackError(operationId, _isolationLevel, _connection, null, e);
                    }
                    else
                    {
                        s_diagnosticListener.WriteTransactionRollbackAfter(operationId, _isolationLevel, _connection, null);
                    }
                    _isFromAPI = false;

                    SqlStatistics.StopTimer(statistics);
                }
            }
        }

Same methods

SqlTransaction::Rollback ( string transactionName ) : void

Usage Example

コード例 #1
0
        public System.Data.SqlClient.SqlTransaction SaveTruck(GINTruckInfo truck, System.Data.SqlClient.SqlTransaction transaction)
        {
            IGINProcess originalGIN = new GINProcessBLL(currentGINProcess.GINProcessInformation.TransactionId);

            currentGINProcess.SaveTruck(truck, transaction);
            //ConfirmNoConcurrency(Truck, Load, Weight)
            var truckChanges = (from oTruck in originalGIN.GINProcessInformation.Trucks
                                where oTruck.TruckId == truck.TruckId
                                select new object[] { oTruck, truck, AuditTrailWrapper.ExistingRecord });

            try
            {
                AuditTrailWrapper atw = new AuditTrailWrapper(AuditTrailWrapper.TruckRegistration, truckChanges.ToArray(), "GIN Process");
                if (!atw.Save())
                {
                    transaction.Rollback();
                    throw new Exception("Failed to save audit trail!");
                }
            }
            catch (Exception ex)
            {
                transaction.Rollback();
                throw ex;
            }
            return(transaction);
        }
All Usage Examples Of System.Data.SqlClient.SqlTransaction::Rollback