/// <summary> /// Start a transaction /// </summary> public static bool CommitTransaction() { bool rc = false; try { if (_trans != null) { _trans.Commit(); _trans.Dispose(); _trans = null; rc = true; } else { throw (new Exception("Commit transaction before begin transaction.")); } return(rc); } finally { Monitor.Exit(_translock); } }
/// <summary> /// Dispose the connection data and be sure to close /// </summary> public override void Dispose() { if (_connection != null) { if (_connection.State != ConnectionState.Closed) { _connection.Close(); } _connection?.Dispose(); } _command?.Dispose(); _transaction?.Dispose(); }
public void Disconnect() { if ((_connection != null) && (_connection.State != ConnectionState.Closed)) { _connection.Close(); } if (_connection != null) { _connection.Dispose(); } if (_transaction != null) { _transaction.Dispose(); } _transaction = null; _connection = null; }