ADO CommandText Property

Home | About me | EXCEL VB Programming (XL97-2003) | ACCESS Programming | EXCEL VB.Net Programming | EXCEL Spreadsheet Functions Material Management  |  Guestbook
 

ADO CommandText Property

The CommandText property sets or returns a string that contains a provider command, like a SQL statement, a table name, a relative URL, or a stored procedure call.

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.

or:

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

Syntax

objcommand.CommandText

Example

Code:

set conn=New ADODB.Connection
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "f:/Mydata/northwind.mdb"
set comm=New ADODB.Command
comm.CommandText="Customers"
debug.print (comm.CommandText)
conn.close
set conn=Nothing
 
Code:
Set objCommand.CommandText = "SELECT FirstName, LastName" & "FROM Customers"