IEstimate.BeginTransaction Method

Starts a database transaction for this estimate's underlying database.
Function BeginTransaction( _ 
Optional ByVal callerName As String = "" _ 
) As Boolean
This language is not supported or no code example is available.
bool BeginTransaction( 
string callerName = "" 
)
This language is not supported or no code example is available.

Parameters

callerName
string

A name of the caller, for example, a type or a method name. It will be used for diagnostic purposes in case of a problem. Can be an empty string.

Return Value

bool

true if the transaction was started; otherwise false, if for any reason the transaction wasn't started.

Remarks
 

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

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.

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