A command object is used to execute a provider-specific text command, such as an SQL statement. Text commands are expressed in a provider-specific language — usually SQL-92 — and are generally used for creating a rowset — for example, executing an SQL SELECT statement.
OLEDB Direct Components Suite has its rowset object, supports prepare/unprepare commands, command parameters.
Simple commands can be executed using TOLEDBDataSource Execute method. These commands are executed in MainSession.
Example:
uses OLEDBComponents;
begin
//Set command text
com.CommandText := 'Insert Into MyTable(Col1, Col2, Col3) Values (?, ?, ?, ?)';
//Prepare command, it is necessary to get parameters info
com.Prepare;
//Get parameters info from provider
com.RefreshParameters;
//Setting parameters requires parameter's accessor
with com.CreateDynamicAccessor do begin
Bindings[0].AsInteger := 1;
Bindings[1].AsInteger := 2;
Bindings[2].AsInteger := 3;
end;
//Execute command
com.Execute;
end;