Accessibility
 
Home > Products > UltraDev > Support > Defining Dynamic Content
Dreamweaver UltraDev Icon Macromedia Dreamweaver UltraDev Support Center - Defining Dynamic Content
Using session variables in database queries

After storing the information in the session variable, you can use it to define the value of a variable in a SQL statement.

To use a session variable to define a SQL variable:

1 In UltraDev, define a recordset using the advanced Recordset dialog box.
For instructions on how to define a recordset, see Using Dreamweaver UltraDev 4 or UltraDev Help.
2 When defining the SQL variable, specify the session variable as the Run-time Value.
In the restaurant example of previous sections of this article, the variables listed in the Recordset dialog box might look as follows.

The expression, Session("location"), provides the value to the SQL variable, varCity, which in turn is used in the SQL statement to filter out all the restaurant reviews not in the user's chosen city.
If you were building a ColdFusion application, the runtime value of varCity would be session.location . With a JSP application, the runtime value would be session.getAttribute("location") .
Note: The Default Value column of the SQL variable contains the wildcard character (%) to display the reviews of all the cities when no run-time value is returned—that is, when the session variable is undefined.
3 Click OK to close the Recordset dialog box.
With this application logic in place, the user needs to specify the city only once—on the application's start page. The web application "remembers" the city and uses it to customize recordsets for the duration of the user's visit.

To Table of Contents Back to Previous document