Opening the Dataset in Batch Update Mode
Go Up to Working with ADO components Index
To open an ADO dataset in batch update mode, it must meet these criteria:
- The component's CursorType property must be ctKeySet (the default property value) or ctStatic.
- The LockType property must be ltBatchOptimistic.
- 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 runtime. 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'; Open; end;
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.