Dreamweaver

Define a recordset without writing SQL

You can create a recordset without manually entering SQL statements.

  1. In the Document window, open the page that will use the recordset.
  2. Select Windows > Bindings to display the Bindings panel.
  3. In the Bindings panel, click the Plus (+) button and select Recordset (Query) from the pop‑up menu.

    The simple Recordset dialog box appears. If you are developing a ColdFusion or ASP.NET site, the Recordset dialog box is slightly different. (If the advanced Recordset dialog appears instead, click the Simple button to switch to the simple Recordset dialog box.)

  4. Complete the Recordset dialog box for your document type.

    For instructions, see the topics below.

  5. Click the Test button to execute the query and ensure that it retrieves the information you intended.

    If you defined a filter that uses parameters input by users, enter a value in the Test Value box, and click OK. If an instance of the recordset is successfully created, a table appears that displays data extracted from the recordset.

  6. Click OK to add the recordset to the list of available content sources in the Bindings panel.

Options for the simple Recordset dialog box (PHP, ASP, JSP)

  1. In the Name box, enter a name for the recordset.

    A common practice is to add the prefix rs to recordset names to distinguish them from other object names in the code, for example: rsPressReleases.

    Recordset names can only contain letters, numbers, and the underscore character (_). You cannot use special characters or spaces.

  2. Select a connection from the Connection pop‑up menu.

    If no connection appears in the list, click Define to create one.

  3. In the Table pop‑up menu, select the database table that will provide data to the recordset.

    The pop‑up menu displays all tables in the specified database.

  4. To include a subset of the table’s columns in the recordset, click Selected and choose the desired columns by Control-clicking (Windows) or Command-clicking (Macintosh) them in the list.

  5. To further limit the records returned from the table, complete the Filter section:

    • From the first pop‑up menu, select a column in the database table to compare against a test value you define.

    • From the second pop‑up menu, select a conditional expression to compare the selected value in each record against the test value.

    • From the third pop‑up menu, select Entered Value.

    • In the box, enter the test value.

      If the specified value in a record meets your filtering condition, the record is included the recordset.

  6. (Optional) To sort the records, select a column to sort by, and then specify whether the records should be sorted in ascending order (1, 2, 3... or A, B, C...) or descending order.

  7. Click Test to connect to the database and create an instance of the data source, and click OK to close the data source.

    A table appears displaying the returned data. Each row contains a record and each column represents a field in that record.

  8. Click OK. The newly defined recordset appears in the Bindings panel.

Options for the simple Recordset dialog box (ColdFusion)

Define a recordset for ColdFusion document types as a source of dynamic content without you having to hand code SQL statements.

Note: If you are creating recordsets for use with ColdFusion 5 or earlier, use the generic Simple Recordset dialog box common to other document types such as ASP and JSP.
  1. In the Name box, enter a name for the recordset.

    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

    Recordset names can only contain letters, numbers, and the underscore character (_). You cannot use special characters or spaces.

  2. If you’re 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.

    The recordset is defined in the function.

  3. Select a data source from the Data Source pop‑up menu.

    If no data source appears in the pop‑up menu, you must create a ColdFusion data source.

  4. In the Username and Password boxes, enter the user name and password for the ColdFusion application server if required.

    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 organization’s ColdFusion administrator.

  5. In the Table pop‑up menu, select the database table that will provide data to the recordset.

    The Table pop‑up menu displays all tables in the specified database.

  6. To include a subset of the table’s columns in the recordset, click Selected and choose the desired columns by Control‑clicking (Windows) or Command-clicking (Macintosh) them in the list.

  7. To further limit the records returned from the table, complete the Filter section:

    • From the first pop‑up menu, select a column in the database table to compare against a test value you define.

    • From the second pop‑up menu, select a conditional expression to compare the selected value in each record against the test value.

    • From the third pop‑up menu, select Entered Value.

    • In the box, enter the test value.

      If the specified value in a record meets your filtering condition, the record is included in the recordset.

  8. (Optional) To sort the records, select a column to sort by, and then specify whether the records should be sorted in ascending (1, 2, 3... or A, B, C...) or descending order.

  9. Click Test to connect to the database and create an instance of the data source.

    A table appears displaying the returned data. Each row contains a record and each column represents a field in that record. Click OK to close the test recordset.

  10. Click OK. The newly defined ColdFusion recordset appears in the Bindings panel.

Options for the simple DataSet dialog box (ASP.NET)

Define an ASP.NET DataSet as a source of dynamic content without hand coding SQL statements.

  1. In the Name box, enter a name for the DataSet.

    A common practice is to add the prefix ds to DataSet names to distinguish them from other object names in your code, for example: dsPressReleases.

    DataSet names can only contain letters, numbers, and the underscore character (_). You cannot use special characters or spaces.

  2. Select a connection from the Connection pop‑up menu.

    If no connection appears in the list, click Define to create one.

  3. In the Table pop‑up menu, select the database table that will provide data to the DataSet.

    The pop‑up menu displays all the tables in the specified database.

  4. To include a subset of the table’s columns in the DataSet, click Selected and choose the desired columns by Control‑clicking (Windows) or Command-clicking (Macintosh) them in the list.

  5. To include only some of the table’s records, complete the Filter section as follows:

    • From the first pop‑up menu, select a column in the database table to compare against a test value you define.

    • From the second pop‑up menu, select a conditional expression to compare the selected value in each record against the test value.

    • From the third pop‑up menu, select Entered Value.

    • In the box, enter the test value.

      If the specified value in a record meets your filtering condition, the record will be included in the DataSet.

  6. (Optional) To sort the records, select a column to sort by, and then specify whether the records should be sorted in ascending order (1, 2, 3... or A, B, C...) or descending order.

  7. You can specify a page to redirect users to if the DataSet query should for some reason fail. For example, if the database were to become unavailable during a query and failed to return the DataSet for the page, you could display an error page with a link to the site’s home page.

  8. Click Test to connect to the database, and create an instance of the data source.

    A table appears displaying the returned data. Each row contains a record and each column represents a field in that record. Click OK to close the DataSet.

  9. Click OK. The newly defined DataSet appears in the Bindings panel.