System.Data.SqlClient Namespace SqlConnection Class
Saves a point within the transaction that can be rolled back to.
[ VB ]
Public Sub SaveTransaction ( _
ByVal savePointName As String _
)
[ C# ]
void SaveTransaction (
string savePointName
);
[ C++ ]
public: void SaveTransaction (
String* savePointName
);
[ JScript ]
public function SaveTransaction (
savePointName : String
);
- savePointName
- The name of the save point within the transaction.
The savePointName can be used in later calls to RollbackTransaction.
The following example initializes an SqlConnection, opens it, begins a transaction, saves a point within the 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.SaveTransaction ( "SampleSavePoint3" );
myConn.RollbackTransaction ( "SampleSavePoint3" );
myConn.Close ( );
}
SqlConnection Members CommitTransaction RollbackTransaction BeginTransaction