CodeCharge Studio

DataSource.SQL Run-Time Property (ASP)

Applies to

DataSource object






object.DataSource.SQL [=value]


This property stores the main part of a query that retrieves data for the form. The main part usually includes the actual SQL command (SELECT), list of fields to be retrieved and a list of tables from which the data will be retrieved (FROM).

The SQL query is eventually built as concatenation of SQL, Where and Order properties.

To modify the SQL property (alter the SQL query), you should use the BeforeBuildSelect event procedure of the form.


This example shows how the SQL property of the DataSource object can be modified to alter the list of values extracted from the database.
Note: The syntax used to concatenate two fields (firstname and lastname) into the name field is not recognized by the standard of SQL language (here it is used for Access database only).
customers.DataSource.SQL = "SELECT customer_id, (firstname & ' ' & lastname) AS name, city FROM customers"

See also

DataSource property
DataSource.Where property
DataSource.Order property

On-line, printable versions and updates