The advanced Recordset dialog box lets you write custom SQL queries, or use the Database Items tree to author SQL queries using a point-and-click interface.
NOTE |
|
If you are creating advanced recordsets for use with ColdFusion 5 or earlier, use the generic advanced Recordset dialog box common to other document types such as ASP and JSP. |
A common practice is to add the prefix rs to recordset names to distinguish them from other object names in your code. For example: rsPressReleases
Note that recordset names can only contain letters, numbers, and the underscore character (_). You cannot use special characters or spaces.
If youre defining a recordset for a ColdFusion component (that is, if a CFC file is currently open in Dreamweaver), select an existing CFC function from the Function pop-up menu, or click the New Function button to create a new function.
NOTE |
|
The Function pop-up menu is only available if a CFC file is the current document and you have access to a computer running ColdFusion MX 7 or better. For more information, see Enabling the ColdFusion enhancements. |
The recordset will be defined in the function. For more information, see Defining a recordset in a ColdFusion component.
If no data source appears in the pop-up menu list, you will need to first create a ColdFusion data source. For more information, see Database Connections for ColdFusion Developers.
Data sources in ColdFusion may require a user name and password to access them. If you do not have the user name and password to access a data source in ColdFusion, contact your organizations ColdFusion administrator.
For more information, see the SQL Primer and Creating SQL queries using the Database Items tree
If you want to use the Database Items tree to build the SQL statement:
For example, if you select a table column, the available buttons are Select, Where, and Order By. Click one of the buttons to add the associated clause to your SQL statement.
If the SQL statement contains parameters, make sure the Default Value column of the Parameters box contains valid test values.
The Page Parameters allow you to provide default values for runtime value references in the SQL you write. For example, the following SQL statement selects an employee record based on the value of the employees ID. You can assign a default value to this parameter, ensuring that a runtime value is always returned. In this example, FormFieldName
refers to a form field in which the user enters their employee ID:
SELECT * FROM Employees WHERE EmpID = + (Request.Form(#FormFieldName
#))
The Add Page Parameters dialog box would contain a name/value paring similar to:
Name |
Default Values |
---|---|
|
0001 |
The runtime value is usually a URL or form parameter entered by a user in an HTML form field. For more information on URL and form parameters, see Retrieving form and URL parameters.
If the SQL statement contains runtime references, make sure the Default Value column of the Page Parameters field contains valid test values before clicking Test.
If successful, a table appears displaying the data in your recordset. Each row contains a record and each column represents a field in that record. Click OK to clear the recordset.