Building queries
As discussed earlier in this chapter, you build queries using the
Note: This and many subsequent procedures use the CompanyInfo data source that connects to the
company.mdb database. This data source is installed by default. For information on adding or
configuring a data source, see Configuring and Administering ColdFusion MX.
To query the table:
Create a ColdFusion page with the following content:
1
<html>
<head>
<title>Employee List</title>
</head>
<body>
<h1>Employee List</h1>
<cfquery name="EmpList" datasource="CompanyInfo">
SELECT FirstName, LastName, Salary, Contract
FROM Employee
</cfquery>
</body>
</html>
Save the page as emplist.cfm in the myapps directory under your web_root directory. For
2
example, the default path on a Windows computer would be:
C:\CFusionMX\wwwroot\myapps\
Enter the following URL in your web browser:
3
http://127.0.0.1/myapps/emplist.cfm
Only the header appears, as the following figure shows:
View the source in the browser:
4
430
Chapter 20: Accessing and Retrieving Data
tag and SQL.
cfquery
Need help?
Do you have a question about the COLDFUSION MX 61-DEVELOPING COLDFUSION MX and is the answer not in the manual?
Questions and answers