Home arrow ColdFusion arrow Page 2 - Databases and Dreamweaver MX 2004, concluded
COLDFUSION

Databases and Dreamweaver MX 2004, concluded


This article, the second of two parts, looks at the different database applications available for use with ColdFusion. It is excerpted from chapter two of the book ColdFusion Web Development with Dreamweaver MX 2004, written by Jen and Peter de Haan et al. (Apress; ISBN: 1590592379).

Author Info:
By: Apress Publishing
Rating: 5 stars5 stars5 stars5 stars5 stars / 10
January 12, 2006
TABLE OF CONTENTS:
  1. · Databases and Dreamweaver MX 2004, concluded
  2. · Using Dreamweaver MX 2004 to Create Queries
  3. · Using Dreamweaver MX 2004ís Advanced Recordset Interface
  4. · Writing a SELECT Query in Advanced Mode
  5. · Filtering by Multiple Parameters

print this article
SEARCH DEVARTICLES

Databases and Dreamweaver MX 2004, concluded - Using Dreamweaver MX 2004 to Create Queries
(Page 2 of 5 )

Letís start by opening Dreamweaver and trying out some simple queries to pull data from our sample database. Open the site you defined in Chapter 1 and you can begin to create some Recordsets. Before proceeding, make sure you have a data source set up, as detailed previously.

  1. Open the Application panel, and then select Bindings->+->Recordset (Query). The dialog box shown in Figure 2-8 will open:


    Figure 2-8.  The Recordset dialog box
  2. Now select our CompanyInfo Data Source from the Data Source drop-down menu. Leave the User Name and Password fields blank, and select Departmt from the Table drop-down menu. For this example, the name of the Recordset is not relevant, so use the default Name, Recordset1. Later, this will be used as a reference name for the code that Dreamweaver will create.
  3. Leave the other fields at their default values and click the Test button. The Test SQL Statement pops up, displaying the search results, as shown in Figure 2-9.

    Our query simply selects all the columns from the Departmt table. If you want to select only certain columns from a table, simply click the Selected radio button next to Columns in the Recordset dialog box, then click on the columns that you wish to select. To select multiple columns, hold Ctrl while clicking on them.
      Figure 2-9.  The results of testing our Recordset 
  4.  Return to the Recordset dialog box by clicking OK. This time, click on the Selected radio button, and then select the Dept_ID and Dept_Name columns. Click on the Test button. You should see the same results as last time, but without the Location column.

You can use the Recordset dialog box to filter out rows as well. Change the Filter drop-down menu selection from None to Location, and then change the URL Parameter drop-down menu selection to Entered Value. Finally, in the text field containing the text Location, change the text to Cambridge as shown in Figure 2-10.


Figure 2-10.  The Recordset dialog box with the filter applied

You will see only three records instead of four. This is because the fourth record was for the location San Francisco, so it wasnít selected by the filter that we set up.

If you want to sort the records by a particular criterion, such as department name, you simply need to change the value in the Sort drop-down menu from None to Dept_Name. Click on Test again, and you will see the three departments in Cambridge sorted by department name in ascending (A to Z) order, as shown in Figure 2-11.


Figure 2-11.  The three departments in Cambridge, sorted in ascending order

To sort the results in reverse order (Z-A), simply change the value in the Sort drop-down menu from Ascending to Descending.

By now, you must have noticed that Dreamweaver allows you to create simple queries without having to write any SQL. Unfortunately, you are limited to simple queries. If you want to write anything more complicated, for example, to order the search results by more than one column, you must switch to the Advanced interface and write some SQL, or manually tweak our SQL code in Code View.

You may have also noticed that you can do onlySELECTqueries in the basic Recordset dialog box, notINSERT,UPDATE, orDELETE statements. If you want to create any of these statements, you must write your own SQL.

Now letís look at creating advanced queries by switching to the Advanced Recordset interface.

NOTE   We will look at INSERT, UPDATE, and DELETE queries later in Chapter 6.


blog comments powered by Disqus
COLDFUSION ARTICLES

- Adobe ColdFusion Just Got More RAD
- How to Access a SQL Anywhere Database with C...
- CFXML: Probing XMLDOM in ColdFusion
- Creating a Web Service with ColdFusion: the ...
- CFAjax: What it is and How to Use it
- Querying SQL 2000 Server from ColdFusion
- Introduction to ColdFusion Markup Language, ...
- Introduction to ColdFusion Markup Language
- Databases and Dreamweaver MX 2004, concluded
- Databases and Dreamweaver MX 2004
- Welcome to Coldfusion MX 6.1, concluded
- Welcome to Coldfusion MX 6.1
- What You Must Know About ColdFusion Flow-Con...
- What You Must Know About Operators in ColdFu...
- Everything You Must Know About ColdFusion Va...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials