IEstimate.CommitTransaction Method

Commits the current database transaction, if any is pending, for this estimate's underlying database.
Sub CommitTransaction()
This language is not supported or no code example is available.
void CommitTransaction()
This language is not supported or no code example is available.
Remarks
 

Use this method if you started the transaction with BeginTransaction. It does nothing, if there is no pending transaction.

This method provides access to the low-level functionality which may be potentially dangerous. To avoid harming the database, use it only if you know exactly what you’re doing.

If another transaction is already started, the method does nothing and returns false. So nested transactions are not allowed.

Example
 

The following example inserts one minute row at the beginning of each task and fills it with some data.

// Process all tasks.
 // If you perform many write operations in a loop, you can try to use manual DB transactions
 // to improve the performance. The speed improvements are not guaranteed, you need to try.
 es.BeginTransaction("My macro");
 
 try
 {
     foreach (ITask task in es.CurrentVersion.Wbs.GetTasksForScope(""))
     {
         if (task.Kind == TaskKind.Task)
         {
             IMinute minute = task.Minute;
             minute.InsertRows(0, 1);
             // Write the values to the estimate, which uses a DB in the background.
             var valuesToWrite = new Dictionary();
             valuesToWrite.Add("Description", "Inserted line");
             valuesToWrite.Add("Unit", "Unit 1");
             minute.SetFieldValue(1, valuesToWrite);
         }
     }
     // Don't forget to commit the transaction when all is OK!
     es.CommitTransaction();
 }
 catch (Exception)
 {
 // Don't forget to roll back the transaction when there's an error!
     es.RollbackTransaction();
 }
 es.RepaintCurrentView();					
This language is not supported or no code example is available.

Version
 
Available since QDV 7.22.1034.

.NET Framework

Supported in: 4.8, 4.7, 4.6, 4.5.2

In this article

Definition