Compartir a través de


Interactively Build a SELECT Statement Sample

File: ...\Samples\Solution\Forms\Makesql.scx

This sample shows how to make it possible for a user to build a custom query at run time. Combo boxes on the form make it possible for a user to choose fields from the currently open table. The BldSQL method processes the names of the fields and the values users type into text boxes to create an executable SQL SELECT statement.

Additional methods, ValidateType and SetTextboxFormat, make sure that the appropriate values are entered into the text boxes and correctly incorporated into the SELECT statement.

After the WHERE clause has been constructed and stored to the variable lcWhere, the following command creates the SELECT statement:

lcSQL = "SELECT * FROM " + lcAlias + " " + lcWHERE

Once the SELECT statement is constructed, it can be executed with macro substitution.

&lcSQL

See Also

Tasks

Solution Samples

Reference

Array Handler Foundation Class

Visual FoxPro Foundation Classes A-Z

Other Resources

Views and Queries Solution Samples