.NET Framework 4.6 and 4.5
Represents a transaction to be made in the database.
Assembly: System.Data.OracleClient (in System.Data.OracleClient.dll)
Thetype exposes the following members.
|Commit||Commits the SQL database transaction. (Overrides DbTransaction.Commit.)|
|CreateObjRef||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||Releases the unmanaged resources used by the DbTransaction. (Inherited from DbTransaction.)|
|Equals(Object)||Determines whether the specified object is equal to the current object. (Inherited from Object.)|
|GetHashCode||Serves as the default hash function. (Inherited from Object.)|
|GetLifetimeService||Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.)|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|InitializeLifetimeService||Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.)|
|Rollback||Rolls back a transaction from a pending state. (Overrides DbTransaction.Rollback.)|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
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