CreateQueryObj(SQL, Database)

Creates a new query object from the system database or an external database to which Sage CRM is connected.

This method can return different data than the FindRecord(TableName, QueryString) method for the following reasons.
The CreateQueryObject method creates a new connection, uses a transaction that is different from the one used for update, and thus can only work with data that is actually in the database. The commit takes place after table-level scripts are run.
The FindRecord(TableName, QueryString) method, however, uses the dispatch connection, so it's the same transaction as the one used by the update. Therefore, this method can work with uncommitted data.

Parameters
  • SQL. Specifies a valid SQL string.
  • Database. Specifies the database to use. When this parameter is omitted, the system database is used by default.
Examples

var Query;
Query = CRM.CreateQueryObj("Select * from vcompany");
Query.SelectSql();
CRM.AddContent(Query.FieldValue("comp_name"));
while (!Query.eof)
{
CRM.AddContent(Query.FieldValue("comp_name") + '
');
Query.NextRecord();
}
Response.Write(CRM.GetPage());

Creates a query object from the company view by using the system database.