Specifying Commands

Commands are set, through Command objects, with two properties. The first of these properties, CommandText, holds either the String value representing the command’s text or the name of a stored command text as the data provider references it. In other words, either the SQL statement SELECT * FROM Authors; can be assigned to the CommandText property, or this string can be stored in the data source and referenced, through the data provider, by a name such as “Get All From Authors”. The CommandType property tells ADO what kind of value resides in the CommandText property. This property would indicate if the value within the CommandText property was a SQL statement or a name of a stored SQL statement. The value of the CommandType property can be set to any valid CommandTypeEnum values as shown in Table 7-1.

Table 7-1. The CommandTypeEnum Enumeration

Value

Description

adCmdText

Indicates that the value of the CommandText property is a definition of a command that the data provider will understand.

adCmdTable

Indicates that the value of the CommandText property is the name of a table within the data source. ADO will create a SQL statement from the table name specified to return all fields within the table.

adCmdTableDirect

Indicates that the value of the CommandText property is the name of a table within the data source. This value is very similar to that of adCmdFile except that the table name is used to return all of the fields within the table rather than ...

Get ADO: ActiveX Data Objects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.