VPE for Visual DataFlex has built in capabilities to use a SQL statement to fetch the records for the report. This makes reporting in VDF much more powerful as you are not constrained by the use of indexes.

In order to tell VPE for VDF to use a SQL statement we need to set a few properties.

Set pbUseSQL to True
Set psDriverID to "MSSQLDRV"
Set pbBindMainFile to True

The pbUseSQL property tells the report class to use SQL statements

Then  we set the psDriverID property to ‘MSSQLDRV’.

In addition we can set the pbBindMainFile property which will cause the report to automatically bind the main file  buffer after fetching a row

We also need to set the psConnectionString property

String sConnStr
Get_Attribute DF_FILE_LOGIN of ORDER.File_Number to sConnStr
Set psConnectionString to sConnStr

in the above example we get the connection string from the order table and use it.

now we need to supply a sql statement

Function GetSQLStatement Returns String
    String sStmt

    Move "Select * from order .... " to sStmt

    Function_Return sStmt
End_Function