asp.net.ph

SqlConnection.RollbackTransaction Method ( String )

System.Data.SqlClient Namespace   SqlConnection Class


Rolls back a database transaction with the transaction name.

[ VB ]
Overloads Public Sub RollbackTransaction ( _
   ByVal transactionName As String _
)

[ C# ]
void RollbackTransaction (
   string transactionName
);

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

[ JScript ]
public function RollbackTransaction (
   transactionName : String
);

Parameters

transactionName
The name of the transaction or save point to rollback.

Exceptions


Exception Type Condition
ArgumentException A transaction name must be specified.

Remarks

There are restrictions when using transactionName with nested transactions: Only the outermost transaction name is registered, so attempting to roll back to a named inner transaction will generate an error.

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

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 ( "SampleTransaction" );
   myConn.RollbackTransaction ( "SampleTransaction" );
   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