Using Command Objects

From RAD Studio
Jump to: navigation, search

Go Up to Working with ADO Components Index

In the ADO environment, commands are textual representations of provider-specific action requests. Typically, they are Data Definition Language (DDL) and Data Manipulation Language (DML) SQL statements. The language used in commands is provider-specific, but usually compliant with the SQL-92 standard for the SQL language.

Although you can always execute commands using TADOQuery, you may not want the overhead of using a dataset component, especially if the command does not return a result set. As an alternative, you can use the Data.Win.ADODB.TADOCommand component, which is a lighter-weight object designed to execute commands, one command at a time. TADOCommand is intended primarily for executing those commands that do not return result sets, such as Data Definition Language (DDL) SQL statements. Through an overloaded version of its Execute method, however, it is capable of returning a result set that can be assigned to the RecordSet property of an ADO dataset component.

In general, working with TADOCommand is very similar to working with TADODataSet, except that you can't use the standard dataset methods to fetch data, navigate records, edit data, and so on. TADOCommand objects connect to a data store in the same way as ADO datasets. See Connecting an ADO Dataset to a Data Store for details.

The following topics provide details on how to specify and execute commands using TADOCommand:

See Also