Although Stonefield Query has a command-line interface that allows you to easily run a report from another application, that mechanism has the downside that Stonefield Query starts and terminates with every report run. Since it can take several seconds to start Stonefield Query (or even longer, depending on any scripts you've created), this can impact performance if several reports are run in a row. In that case, you may wish to use the SQProxy object.

SQProxy is a lightweight COM object included in SQProxy.EXE (which means, of course, that you need to distribute and register that EXE if you want to use this object on your users' systems). It acts as a manager for the Stonefield Query application so it can be started and kept in memory, without displaying any user interface, meaning the startup tasks are only performed once rather than on every report run.

SQProxy has a single method: LoadProject. After instantiating the SQProxy object, call its LoadProject method to load the specified project. This method accepts four parameters: the path for the project files, the user name, the password, and the name of the data source to query against. The last parameter is optional; if you don't pass it, the data source used last time Stonefield Query was run is used. Once you've called LoadProject, you can reference its SQApplication member, which is an instance of the Stonefield Query Application object, giving you full access to all of its members.

In addition to SQApplication, SQProxy has three other properties:

Here's an example that instantiates SQProxy, loads the Northwind project as the ADMIN user, and runs the Customers and History reports to a couple of PDF files:

loQuery = createobject('SQProxy.SQProxy')
loQuery.LoadProject('\MyProjects\Northwind', 'admin', 'admin')
if loQuery.ProjectLoaded
  llSuccess = loQuery.SQApplication.ReportEngine.RunReportToFile('Customers', ;
    '\MyReports\customers.pdf')
  if not llSuccess
    messagebox(loQuery.SQApplication.ReportEngine.ErrorMessage)
  endif
  llSuccess = loQuery.SQApplication.ReportEngine.RunReportToFile('History', ;
    '\MyReports\history.pdf')
  if not llSuccess
    messagebox(loQuery.SQApplication.ReportEngine.ErrorMessage)
  endif
endif

See the ReportEngine Object help topic for methods available to run reports.