Using a variable as a data source for a ColdFusion recordset

Using a variable as a data source for a ColdFusion recordset

When you define a recordset for a page in the Bindings panel, Dreamweaver enters the name of the ColdFusion data source in the cfquery tag on the page. For more flexibility, you can store a data source name in a variable and use the variable in the cfquery tag. Dreamweaver provides a visual method of specifying such a variable in your recordsets.

To visually specify a variable as a data source for a recordset:

  1. Make sure a ColdFusion page is active in the Document window.
  2. In the Bindings panel, click the Plus (+) button and select Data Source Name Variable from the pop-up menu.

    The Data Source Name Variable dialog box appears.

  3. Define a variable and click OK.
  4. When defining the recordset, select the variable as the Data Source for the recordset.

    In the Recordset dialog box, the variable appears in the Data Source pop-up menu along with the ColdFusion data sources on the server.

  5. Complete the Recordset dialog box and click OK.
  6. Initialize the variable.

    Dreamweaver does not initialize the variable for you so that you can initialize it how and where you want. You can initialize the variable in the page code (before the cfquery tag), in an include file, or in some other file as a session or application variable.

Getting Started with Dreamweaver
Dreamweaver Basics
Working with Dreamweaver Sites
Laying Out Pages
Adding Content to Pages
Working with Page Code
Preparing to Build Dynamic Sites
Making Pages Dynamic
Defining Sources of Dynamic Content
Developing Applications Rapidly