ADO » Command » CommandType

commandobject.CommandType = CommandTypeEnum
CommandTypeEnum = commandobject.CommandType

Sets or returns the CommandTypeEnum type of the Command object.

The CommandType property sets or returns a CommandTypeEnum constant that defines the type of the Command object.
The default is adCmdUnknown. If the specific type declared using the CommandType property does not match the actual type of the Command object, an error will be generated when the Execute method is called.
If you do not specify the type, ADO will need to contact the provider to determine the type of the command. In contrast, if you do specify the type, ADO will usually be able to process the command faster. This is a very simple, yet expedient way to optimize submitting a Command against a data source.
You may also combine the adExecuteNoRecords constant from the ExecuteOptionEnum constants with the adCmdText or adCmdStoredProc constants of the CommandTypeEnum constants to speed up processing.
CommandTypeEnum Constants

Constant Value Description
adCmdFile 256 Evaluate as a previously persisted file
adCmdStoredProc 4 Evaluate as a stored procedure
adCmdTable 2 Have the provider generate a SQL query and return all rows from the specified table
adCmdTableDirect 512 Return all rows from the specified table
adCmdText 1 Evaluate as a textual definition
adCmdUnknown 8 The type of the CommandText parameter is unknown
adCmdUnspecified -1 Default, does not specify how to evaluate

ExecuteOptionEnum Constants
Constant Value Description
adExecuteNoRecords 0x80 Does not return rows and must be combined with adCmdText or adCmdStoredProc


Set objCommand = Server.CreateObject("ADODB.Command")
Set objCommand.ActiveConnection = strConnection
objCommand.CommandType = adCmdText OR adExecuteNoRecords

See Also: