What Happens When a User Accesses My ASP Page?

An Outline of a WordPage Document

WordPage does all of its work during the authoring process and when you select the “Create ASP” item on the WordPage menu. At that time it generates the HTML and VBScript code that will carry out the actions you have requested. This section discusses the structure of the ASP documents that WordPage creates and how they execute when a user requests them. The general outline of the ASP document is:

  1. Create an ADO connection to the database.
  2. If a manual select is being used get the command
  3. If the document is using a generated select…
    1. For all fields that allow filters examine the request for a filter.
    2. For each filter that is found translate the value according to the syntax discussed below.
    3. If allowed by the author, examine the request for information to build the order by clause.
  4. If the request includes “_ShowSQL=1” display the command before it is executed.
  5. Execute the command
  6. If the document has a StartLoop…EndLoop
    1. Initialize the total variables.
    2. If more records exist process the document until the EndLoop is encountered.
    3. Update total variables.
    4. Move to the next record in the datasource.
    5. Go back to the StartLoop and repeat steps b through e.

 

Many other types of processing are possible by embedding VBScript commands in the document enclosed in curly braces {}.

The Syntax of a User-Supplied Filter

If a datasource uses a generated select you have the option of allowing filters to be included in the request from the browser. The name of the filter is the field name with “_flt” appended. For example if the field is CompanyName the filter is named CompanyName_flt. The syntax is designed to be easy to supply both in a hyperlink and with an edit field in an HTML form. The results of the filter on each field are combined with an “and” operation. For information about creating filter fields click here.

 

The filter value is broken into its component parts. For date data semi-colons separate the parts. For all other data types the separator is a comma. Each piece is independently translated into a string that is valid as part of a SQL WHERE or HAVING clause. The results are combined with an OR operator to produce the final clause.

 

Each piece may begin with a comparison operator. The available operators are:

=

Equals

>

Greater than

<

Less than

>=

Greater than or equal

<=

Less than or equal

<>

Not equal

!

Not equal

 

If the piece has no comparison operator then it may have a range specification. Either “ to” or “…” is valid to specify a range. If the piece contains an asterisk it is regarded as a wildcard. This list shows a variety of valid request filters.

OrderID_flt=100

Amount_flt=>5000

OrderDate_flt=1/1/1999 to 12/31/1999

CompanyName_flt=*fish*

LastName_flt=smith,jones,*son

OrderID_flt=100..200,300..400,>1000

 

The Syntax of a User-Supplied Sort

If the option to allow sorts in the request is checked in the datasource, WordPage allows up to five sort fields to be specified in the request. Sorts are specified similarly to filters. The syntax is Sortn=fieldname where “n” is a number from 1-5. FieldName can be prefixed by a minus sign to request a descending sort.

An Example URL

Here is a complete URL and an explanation of its parts:

http://localhost/test.asp?sort1=-amount&Amount_flt=>25000&companyname_flt=*ak*

 

http://localhost/test.asp

Request the page “test.asp” from the web server named “localhost”.

Sort1=-amount

Request a descending sort by the amount field.

Amount_flt=>25000

Only show records where the amount value is greater than 25000.

Companyname_flt=*ak*

Only show records where the company name has “ak” somewhere inside it.