IAxapta::ExecuteStmt

HRESULT ExecuteStmt(

  [in] BSTR bstrStmt,

  [in] VARIANT record1,

  [in, optional] VARIANT record2,

  [in, optional] VARIANT record3,

  [in, optional] VARIANT record4,

  [in, optional] VARIANT record5,

  [in, optional] VARIANT record6,

);

Executes a statement on the specified Axapta records.

The statement must be a Microsoft Axapta X++ statement. A valid a statement could be: select * from %1 where %2.Name == ‘Axapta’. This statement requires two Microsoft Axapta records, one for %1 (record1) and one for %2 (record2). The %-signs are automatically substituted with the corresponding record names.

This method offers the same functionality as IAxapta::ExecuteStmtEx and the method accepts up to 6 Microsoft Axapta records. If more than 6 Microsoft Axapta records are needed then IAxapta::ExecuteStmtEx must be used.

Parameters

bstrStmt

The statement to execute on the specified records.

record1-record6

Microsoft Axapta records to replace the %-signs in the bstrStmt. record2 to record6 are optional.

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 Microsoft 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

 

Set Axapta = CreateObject("AxaptaCOMConnector.Axapta")

 

Axapta.Logon

 

‘ create an Axapta record

Set MyRecord = Axapta.CreateRecord("MyTable")

 

Axapta.ExecuteStmt "select * from %1 where %1.Name == ’MyName’", MyRecord

 

While MyRecord.Found

  txt = MyRecord.Field("Address")

 

  ‘ do something with the address in "txt"

 

  ‘ get the next record

  MyRecord.Next

Wend