The Execute method on a Command object executes the statement specified in the CommandText property.
command.Execute( RecordsAffected, Parameters, Options )
set recordSet = command.Execute( RecordsAffected, Parameters, Options )
The CommandTypeEnum value can be one of the following constants:
Enumeration | Value | Description |
---|---|---|
adCmdUnspecified | -1 | This value indicates that the CommandText property is unspecified and is not supported by the OLE DB Provider for AS/400 and VSAM. |
adCmdText | 1 | This value evaluates the CommandText property as a text string and is the only supported Options parameter for this method using the OLE DB Provider for AS/400 and VSAM. |
adCmdTable | 2 | This value evaluates the CommandText property as a table name and is not supported by the OLE DB Provider for AS/400 and VSAM. |
adCmdStoredProc | 4 | This value evaluates the CommandText property as a stored procedure and is not supported by the OLE DB Provider for AS/400 and VSAM. |
adCmdUnknown | 8 | This value indicates that the type of command in CommandText is not known and is not supported by the OLE DB Provider for AS/400 and VSAM. |
The default for Option is AdCmdText under the OLE DB Provider for AS/400 and VSAM.
The Execute method on a Command object can be used to open tables or execute DDM commands on a remote DDM server. The Options parameter must be set to adCmdText for use with the OLE DB Provider for AS/400 and VSAM
The primary purpose of the Command object in the context of the OLE DB Provider for AS/400 and VSAM is to issue AS/400 Command Language (CL) commands for execution by the remote OS/400 DDM target server. To invoke DDM commands on a remote DDM server, the CommandText property defines the text version of a command which must have been set to:
EXEC COMMAND DDMCmd
where DDMCmd represents a valid AS/400 CL command. Legal DDM command-line strings are documented in Chapter 5 of the AS/400 DDM User's Guide published by IBM.
Note that this method does not return the results or output of a remote DDM CL command. If the results or output of a remote command are to be captured, the DDMCmd statement to be executed must include syntax to redirect the command output to a file on the AS/400 host and then explicitly open this output file after the command has completed.
The Execute method on a Command object can also be used to open a data file after a Connection object has been opened and the ActiveConnection property has been set to this open connection. The CommandText property defines the data file to open and must be set to:
EXEC OPEN DataSetName
where DataSetName represents a valid data file or library member on the host. When used in this way, the Execute method returns a Recordset object. If you open a host data file from a Command object, then the data file is opened as read-only. This results from the limitation that no argument or option is passed by ADO that supplies a parameter describing whether the data set should be opened as read-only or updatable.
If errors occur, these can be examined with the Errors collection on the Command object.