Opening the Dataset in Batch Update Mode

From RAD Studio
Jump to: navigation, search

Go Up to Connecting an ADO Dataset to a Data Store

To open an ADO dataset in batch update mode, it must meet these criteria:

  1. The component's CursorType property must be ctKeySet (the default property value) or ctStatic.
  2. The LockType property must be ltBatchOptimistic.
  3. The command must be a SELECT query.

Before activating the dataset component, set the CursorType and LockType properties as indicated above. Assign a SELECT statement to the component's CommandText property (for TADODataSet) or the SQL property (for TADOQuery). For TADOStoredProc components, set the ProcedureName to the name of a stored procedure that returns a result set. These properties can be set at design-time through the Object Inspector or programmatically at run time. The example below shows the preparation of a TADODataSet component for batch update mode.

with ADODataSet1 do begin
  CursorLocation := clUseClient;
  CursorType := ctStatic;
  LockType := ltBatchOptimistic;
  CommandType := cmdText;
  CommandText := 'SELECT * FROM Employee';
ADODataSet1->CursorLocation = clUseClient;
ADODataSet1->CursorType = ctStatic;
ADODataSet1->LockType = ltBatchOptimistic;
ADODataSet1->CommandType = cmdText;
ADODataSet1->CommandText = "SELECT * FROM Employee";

After a dataset has been opened in batch update mode, all changes to the data are cached rather than applied directly to the base tables.

See Also