System.Data.SqlClient.SqlTransaction.Commit Method

Commits the database transaction.

Syntax

public override void Commit ()

Remarks

The SqlTransaction.Commit method is equivalent to the Transact-SQL COMMIT TRANSACTION statement. You cannot roll back a transaction once it has been committed, because all modifications have become a permanent part of the database. For more information, see SQL Server Books Online.

Note:

Try/Catch exception handling should always be used when committing or rolling back a System.Data.SqlClient.SqlTransaction. Both Commit and SqlTransaction.Rollback generates an InvalidOperationException if the connection is terminated or if the transaction has already been rolled back on the server.

For more information on SQL Server transactions, see "Explicit Transactions" and "Coding Efficient Transactions" in SQL Server Books Online.

Requirements

Namespace: System.Data.SqlClient
Assembly: System.Data (in System.Data.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0