As discussed earlier in this chapter, you build queries using the CFQUERY tag and SQL.
|To query the employees table:|
<CFQUERY NAME="EmpList" DATASOURCE="HRExpress"> SELECT FirstName,LastName, StartDate, Salary, Contract FROM Employees </CFQUERY>
The DATASOURCE attribute that you enter here refers to the data source that you created.
EmpList.cfmin CFDOCS under the Web root directory.
For example, the directory path on your machine may be:
C:\INETPUB\WWWROOT\CFDOCS on Windows NT
C:\WEBSHARE\WWWROOT\CFDOCS on Windows 95
Your page should look like this:
<HTML> <HEAD> <TITLE>Employee List</TITLE> </HEAD> <BODY> <H1>Employee List</H1> <CFQUERY NAME="EmpList" DATASOURCE="HRExpress"> SELECT FirstName,LastName, StartDate, Salary, Contract FROM Employees </CFQUERY> </BODY> </HTML>
The ColdFusion EmpList data set is stored with the page but only HTML and text is sent back to the browser.
Click here to see how the query page should look at this time.
Click here to see the code behind the scenes.
|Note:||HomeSite editing and visual tools make it easy to build queries. Refer to the Help tab in HomeSite to learn more about its features.|