📚 SAP Business One SDK Help

ExecuteQuery Method
See Also  Example
Query

A SQL query

Description

Runs the specified SQL query.

Syntax

Visual Basic
Public Sub ExecuteQuery( _
   ByVal Query As String _
) 

Parameters

Query

A SQL query

Remarks

The system does not validate the SQL.

If the query result is empty, the DataTable.Rows.Count property is set to 1.

To query a user-defined table, put the table name within square brackets. This is because the @ symbol before the table name is a reserved symbol in SQL Server. For example:

DataTable.ExecuteQuery "select * from [@usertablename]"

Example

Executing a query (Visual Basic)Copy Code
Set oDataTable = oForm.DataSources.DataTables.Item(m_DataTableUid)
queryStr = "Select 0, CardName, CardType, GroupNum from OCRD"
oDataTable.ExecuteQuery queryStr

See Also