IAxapta::ExecuteStmtEx
HRESULT ExecuteStmtEx(
[in] BSTR bstrStmt,
[in] IAxaptaParameterList *pParamList
);
Executes a statement on the specified Microsoft Axapta records.
The statement must be an Microsoft Axapta X++ statement. A valid a statement could be: select * from %1 where %2.Name == ‘Axapta’. This statement requires two Microsoft Axapta records in the parameter list, one for %1 and one for %2. The %-signs are automatically substituted with the corresponding record names.
This method offers the same functionality as IAxapta::ExecuteStmt whereas the Microsoft Axapta records are specified in a parameter list. Where the IAxapta::ExecuteStmt accepts up to 6 Axapta records the parameter list allows a greater number of Microsoft Axapta records to be specified.
Parameters
bstrStmt
The statement to execute on the specified records.
pParamList
Parameter list containing the Axapta records to replace the %-signs in the bstrStmt. The parameter list is a COM object of the IAxaptaParameterList type.
Return Value
The return value obtained from the returned HRESULT is one of the following:
Return value |
Meaning |
S_OK |
Success |
E_FAIL |
General failure |
E_INVALIDARG |
One or more of the arguments is invalid |
The IAxapta object is not logged on |
|
The security key for using class objects through the Axapta Business Connector is disabled |
Comments
If only one Microsoft Axapta record is specified in the bstrStmt it is often more convenient to used the IAxaptaRecord::ExecuteStmt method.
Example (Visual Basic)
Dim Axapta As Object
Dim MyRecord As Object
Dim ParameterList As Object
Set Axapta = CreateObject("AxaptaCOMConnector.Axapta")
Set ParameterList = CreateObject("AxaptaCOMConnector.AxaptaParameterList")
Axapta.Logon
‘ create an Axapta record
Set MyRecord = Axapta.CreateRecord("MyTable")
‘ set up parameter list
ParameterList.Size = 1
ParameterList.Element(1) = MyRecord
Axapta.ExecuteStmtEx "select * from %1 where %1.Name == ’MyName’", ParameterList
While MyRecord.Found
txt = MyRecord.Field("Address")
‘ do something with the address in "txt"
‘ get the next record
MyRecord.Next
Wend