ADO » Command » CommandText

commandobject.CommandText = string
string = commandobject.CommandText

Sets or returns the text of a command statement to be applied against a data provider.

The CommandText property sets or returns a string that is a text command that can be applied to a data source.
The text command can be any type of command that will be recognized by the provider, such as an SQL statement, a stored procedure, a table name, or a relative URL that specifies a file, folder or resource. The SQL language must be a version that is supported by the provider. The default is the empty string "".
If you need to use the same command repeatedly (even with different parameters) during a connection, set the Prepared property of the Command object to be True. This will cause the command to be compiled and stored for the life of the connection.


Note that the CommandStream and CommandText properties are mutually exclusive; setting one will clear the other.



Set objCommand.CommandText = "SELECT FirstName, LastName" & _
                                                   " FROM GuruStaffList"
Set objCommand.CommandText = "GuruMeditationTable('Name', 'Guru')"

See Also: