The SqlTransaction Class

The SqlTransaction Class

There are three Transaction classes: SqlTransaction, OleDbTransaction, and OdbcTransaction. You use a Transaction object to represent a database transaction, and an object of the SqlTransaction class to represent a database transaction in a SQL Server database. Table 14.1 shows some of the SqlTransaction properties, and Table 14.2 shows some of the SqlTransaction methods. You'll see the use of some of these properties and methods in this chapter.

Table 14.1: SqlTransaction PROPERTIES

PROPERTY

TYPE

DESCRIPTION

Connection

SqlConnection

Gets the connection for the transaction.

IsolationLevel

IsolationLevel

Gets the isolation level for the transaction (see "Setting the Transaction Isolation Level").

Table 14.2: SqlTransaction METHODS

METHOD

RETURN TYPE

DESCRIPTION

Commit()

void

Performs a commit to permanently record the SQL statements in the transaction.

Rollback()

void

Overloaded. Performs a rollback to undo the SQL statements in the transaction.

Save()

void

Creates a savepoint in the transaction that can be used to undo a portion of that transaction. The string passed to this method specifies the savepoint name. You can then roll back the transaction to that savepoint (see "Setting a Savepoint").




Mastering C# Database Programming
Mastering the SAP Business Information Warehouse: Leveraging the Business Intelligence Capabilities of SAP NetWeaver
ISBN: 0764596373
EAN: 2147483647
Year: 2003
Pages: 181

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net