RollbackTransaction Method
后续版本的 Microsoft SQL Server 将删除该功能。请避免在新的开发工作中使用该功能,并着手修改当前还在使用该功能的应用程序。
The RollbackTransaction method ends a unit of work explicitly opened by a corresponding BeginTransaction method call, discarding any change(s) applied within the work unit.
语法
object
.RollbackTransaction( [ SavePoint ] )
Parts
- object
Expression that evaluates to an object in the Applies To list.
- SavePoint
Optional. A string that identifies a save point in the transaction.
Prototype (C/C++)
HRESULT RollbackTransaction(
SQLDMO_LPCSTR TransactionOrSavepointName = NULL);
备注
Use the BeginTransaction, CommitTransaction, and RollbackTransaction methods to implement application-defined transaction units.
When unqualified by the optional argument, the RollbackTransaction method undoes an entire transaction. Use the SaveTransaction method to set transaction midpoints, then specify the most recent midpoint in the SavePoint argument to undo only those changes applied after the point in the transaction. For more information, see SaveTransaction Method.
注意: |
---|
SQL Distributed Management Objects (SQL-DMO) implements objects that can be used to automate Microsoft SQL Server administration. Most administrative functions use data definition language (DDL) statements for their implementation. Generally, application-defined transaction units are not respected by DDL. Where SQL Server does not implement transaction space for DDL, SQL-DMO does not extend DDL by defining a transaction space. |
In general, use the BeginTransaction, CommitTransaction, and RollbackTransaction methods only when submitting Transact-SQL command batches for execution by using methods such as ExecuteImmediate. It is suggested that you do not leave transaction units open but either commit or roll back the unit when the command batch execution method is complete.