Name

Command.CommandText Property — (Versions 2.0, 2.1, 2.5, 2.6)

Synopsis

                     Command.CommandText = CommandText
                  

The CommandText property sets or returns a valid SQL statement, table name, stored procedure name, relative URL, or any other command text that the data provider may recognize.

Datatype

String

Description

The CommandText property contains a String value that by default contains a zero-length string (“”). This string can be set to a SQL statement, table name, stored procedure call, relative URL, or any other command text that the data provider may recognize.

The CommandType property is used to indicate to ADO what type of information resides within the CommandText property. If the CommandType property is set to adCmdText, it indicates to the provider that the CommandText property value contains a text command that the provider will understand. This will usually be a SQL statement, but not necessarily.

If you set the CommandText property, ADO prepares the specified query on the Execute or Open methods whenever the Prepared property of the Command object is set to True, and it is bound to an open connection.

The value of CommandText may be changed by ADO, depending on the value of the CommandType property. Retrieve the value of the CommandText property at any time if you question its value.

If the CommandStream property is set to a value, then the CommandText property is automatically set to an empty string (“”).

See Also

Command.CommandStream, Command.CommandType Property, Command.Dialect ...

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.