OracleTransaction OracleTransaction OracleTransaction OracleTransaction Class

정의

데이터베이스에 만들 트랜잭션을 나타냅니다.Represents a transaction to be made in the database.

public ref class OracleTransaction sealed : System::Data::Common::DbTransaction
public sealed class OracleTransaction : System.Data.Common.DbTransaction
type OracleTransaction = class
    inherit DbTransaction
Public NotInheritable Class OracleTransaction
Inherits DbTransaction
상속
OracleTransactionOracleTransactionOracleTransactionOracleTransaction

예제

다음 예제는 OracleConnectionOracleTransaction합니다.The following example creates an OracleConnection and an OracleTransaction. 사용 하는 방법을 보여 줍니다 합니다 BeginTransaction, Commit, 및 Rollback 메서드.It also demonstrates how to use the BeginTransaction, Commit, and Rollback methods.

public void RunOracleTransaction(string connectionString)
{
    using (OracleConnection connection = new OracleConnection(connectionString))
    {
        connection.Open();

        OracleCommand command = connection.CreateCommand();
        OracleTransaction transaction;

        // Start a local transaction
        transaction = connection.BeginTransaction(IsolationLevel.ReadCommitted);
        // Assign transaction object for a pending local transaction
        command.Transaction = transaction;

        try
        {
            command.CommandText = 
                "INSERT INTO Dept (DeptNo, Dname, Loc) values (50, 'TECHNOLOGY', 'DENVER')";
            command.ExecuteNonQuery();
            command.CommandText = 
                "INSERT INTO Dept (DeptNo, Dname, Loc) values (60, 'ENGINEERING', 'KANSAS CITY')";
            command.ExecuteNonQuery();
            transaction.Commit();
            Console.WriteLine("Both records are written to database.");
        }
        catch (Exception e)
        {
            transaction.Rollback();
            Console.WriteLine(e.ToString());
            Console.WriteLine("Neither record was written to database.");
        }
    }
}
Public Sub RunOracleTransaction(ByVal connectionString As String)
    Using connection As New OracleConnection(connectionString)
        connection.Open()

        Dim command As OracleCommand = connection.CreateCommand()
        Dim transaction As OracleTransaction

        ' Start a local transaction
        transaction = connection.BeginTransaction(IsolationLevel.ReadCommitted)
        ' Assign transaction object for a pending local transaction
        command.Transaction = transaction

        Try
            command.CommandText = _
                "INSERT INTO Dept (DeptNo, Dname, Loc) values (50, 'TECHNOLOGY', 'DENVER')"
            command.ExecuteNonQuery()
            command.CommandText = _
                "INSERT INTO Dept (DeptNo, Dname, Loc) values (60, 'ENGINEERING', 'KANSAS CITY')"
            command.ExecuteNonQuery()
            transaction.Commit()
            Console.WriteLine("Both records are written to database.")
        Catch e As Exception
            transaction.Rollback()
            Console.WriteLine(e.ToString())
            Console.WriteLine("Neither record was written to database.")
        End Try
    End Using
End Sub

설명

애플리케이션을 만듭니다는 OracleTransaction 개체를 호출 하 여 BeginTransactionOracleConnection 개체입니다.The application creates an OracleTransaction object by calling BeginTransaction on the OracleConnection object. 예를 들어, 커밋, 트랜잭션을 중단 트랜잭션과 관련 된 모든 후속 작업에서 수행 되는 OracleTransaction 개체입니다.All subsequent operations associated with the transaction (for example, committing or aborting the transaction), are performed on the OracleTransaction object.

속성

Connection Connection Connection Connection

트랜잭션과 관련된 OracleConnection 개체를 지정합니다.Specifies the OracleConnection object associated with the transaction.

IsolationLevel IsolationLevel IsolationLevel IsolationLevel

이 트랜잭션에 대한 IsolationLevel을 지정합니다.Specifies the IsolationLevel for this transaction.

메서드

Commit() Commit() Commit() Commit()

SQL 데이터베이스 트랜잭션을 커밋합니다.Commits the SQL database transaction.

CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

원격 개체와 통신하는 데 사용되는 프록시 생성에 필요한 모든 관련 정보가 들어 있는 개체를 만듭니다.Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
Dispose() Dispose() Dispose() Dispose()

이 개체에서 사용하는 리소스를 해제합니다.Releases the resources used by this object.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

지정한 개체와 현재 개체가 같은지 여부를 확인합니다.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

기본 해시 함수로 작동합니다.Serves as the default hash function.

(Inherited from Object)
GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

이 인스턴스의 수명 정책을 제어하는 현재의 수명 서비스 개체를 검색합니다.Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetType() GetType() GetType() GetType()

현재 인스턴스의 Type을 가져옵니다.Gets the Type of the current instance.

(Inherited from Object)
InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

이 인스턴스의 수명 정책을 제어하는 수명 서비스 개체를 가져옵니다.Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

현재 MarshalByRefObject 개체의 단순 복사본을 만듭니다.Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
Rollback() Rollback() Rollback() Rollback()

보류 상태에서 트랜잭션을 롤백합니다.Rolls back a transaction from a pending state.

ToString() ToString() ToString() ToString()

현재 개체를 나타내는 문자열을 반환합니다.Returns a string that represents the current object.

(Inherited from Object)

적용 대상

추가 정보