Firebird ADO.NET Provider SDK Documentation - v1.7

FbTransaction.Save Method 

Establish a new Save point for the current transaction with the given name.

[Visual Basic]
Public Sub Save( _
   ByVal savePointName As String _
)
[C#]
public void Save(
   string savePointName
);

Parameters

savePointName
The savepoint name.

Remarks

Savepoints offer a mechanism to roll back portions of transactions. You create a savepoint using the Save method, and then later call the Rollback method to roll back to the savepoint instead of rolling back to the start of the transaction.

Exceptions

Exception TypeCondition
FbExceptionAn error occurred while trying to commit the transaction.
InvalidOperationExceptionThe transaction has already been committed or rolled back.
InvalidOperationExceptionFbCommand is currently busy Open, Fetching.

Example

FbConnection myConnection = new FbConnection(connectionString);
myConnection.Open();

FbCommand myCommand = new FbCommand();
FbTransaction myTrans;

// Start a local transaction
myTrans = myConnection.BeginTransaction();
// Assign transaction object for a pending local transaction
myCommand.Connection = myConnection;
myCommand.Transaction = myTrans;

try
{
    myCommand.CommandText = "INSERT INTO PROJECT(proj_id, proj_name, product) Values('FBNP', '.Net Provider', 'N/A')";
    myCommand.ExecuteNonQuery();
    myTrans.Save("SampleTransaction");
    myCommand.CommandText = "INSERT INTO PROJECT(proj_id, proj_name, product) Values('FBN1', '.Net Provider1.', 'N/A')";
    myCommand.ExecuteNonQuery();
    myTrans.Commit();
    Console.WriteLine("Both records are written to database.");
}
catch(Exception e)
{
    try
    {
        myTrans.Rollback("SampleTransaction");
    }
    catch (FbException ex)
    {
        if (myTrans.Connection != null)
        {
            Console.WriteLine("An exception of type " + ex.GetType() +
                " was encountered while attempting to roll back the transaction.");
        }
    }

    Console.WriteLine("An exception of type " + e.GetType() +
        " was encountered while inserting the data.");
    Console.WriteLine("Neither record was written to database.");
}
finally 
{
    myConnection.Close();
}        
                

See Also

FbTransaction Class | FirebirdSql.Data.Firebird Namespace