Accessing the Connection's Datasets

From RAD Studio
Jump to: navigation, search

Go Up to Connecting to ADO Data Stores


Like other database connection components, you can access the datasets associated with the connection using the DataSets and DataSetCount properties. However, dbGo also includes Data.Win.ADODB.TADOCommand objects, which are not datasets, but which maintain a similar relationship to the connection component.

You can use the Commands and CommandCount properties of TADOConnection to access the associated ADO command objects in the same way you use the DataSets and DataSetCount properties to access the associated datasets. Unlike DataSets and DataSetCount, which only list active datasets, Commands and CommandCount provide references to all TADOCommand components associated with the connection component.

Commands is a zero-based array of references to ADO command components. CommandCount provides a total count of all of the commands listed in Commands. You can use these properties together to iterate through all the commands that use a connection component, as illustrated in the following code:

Delphi:

var
   i: Integer
begin
  for i := 0 to (ADOConnection1.CommandCount - 1) do
    ADOConnection1.Commands[i].Execute;
end;

C++:

 for (int i = 0; i < ADOConnection2->CommandCount; i++)
   ADOConnection2->Commands[i]->Execute();

See Also