asp.net.ph

SqlConnection.RollbackTransaction Method ( )

System.Data.SqlClient Namespace   SqlConnection Class


Rolls back a transaction from being applied to the database.

[ VB ]
Overloads Overrides Public Sub RollbackTransaction ( )

[ C# ]
public override void RollbackTransaction ( );

[ C++ ]
public: void RollbackTransaction ( );

[ JScript ]
public override function RollbackTransaction ( )

Exceptions


Exception Type Condition
Exception An error occured while trying to execute the transaction.

Remarks

The transaction can only be rolled back from a pending state ( after BeginTransaction has been called, but before CommitTransaction is called ).

Notes to Inheritors: When overriding RollbackTransaction in a derived class, be sure to call the base class's RollbackTransaction method.

Example

The following example initializes an SqlConnection, opens it, begins a transaction, rollsback the transaction, then closes the connection. To accomplish this, the method is passed an SQL connection string to use to connect to the data source.

void RunSqlTransaction ( string strConn ) {
   SqlConnection myConn = new SqlConnection ( strConn );
   myConn.Open ( );
   myConn.BeginTransaction ( );
   myConn.RollbackTransaction ( );
   myConn.Close ( );
}
See Also

SqlConnection Members   SqlConnection.RollbackTransaction Overload List   CommitTransaction   SaveTransaction   BeginTransaction Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph