The Execute method on a Connection object executes the statement specified in the CommandText property.
connection.Execute CommandText, RecordsAffected, Options
set recordset = connection.Execute( CommandText, RecordsAffected, 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 (not supported by the OLE DB Provider for AS/400 and VSAM). |
adCmdText | 1 | This value evaluates the CommandText property as a text string. |
adCmdTable | 2 | This value evaluates the CommandText property as a table name (not supported by the OLE DB Provider for AS/400 and VSAM). |
adCmdStoredProc | 4 | This value evaluates the CommandText property as a stored procedure (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 Execute method on a Connection 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 Execute method on a Connection object is primarily used to open a data file after a Connection object has been created. 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 Connection 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 a Recordset object is desired that is not read-only, then first create a Recordset object with the desired property settings, and use the Recordset object's Open method to return the open Recordset.
The Execute method on a Connection object can also be used 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.
If errors occur, these can be examined with the Errors collection on the Connection object.