asp.net.ph

SqlConnection.RollbackTransaction Method

System.Data.SqlClient Namespace   SqlConnection Class


Rolls back a database transaction from a pending state.

Overload List

1. 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 ( );

2. Rolls back a database transaction with the transaction name.

[ VB ] Overloads Public Sub RollbackTransaction ( String )

[ C# ] void RollbackTransaction ( string );

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

[ JScript ] public function RollbackTransaction ( String );


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.

NOTE: This example shows how to use one of the overloaded versions of RollbackTransaction. For other examples that may be available, see the individual overload topics.

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

SqlConnection Members Skip Navigation Links


Previous page Back to top Next page

Check out related books at Amazon

© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

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