There are two basic Cold Fusion commands: <cfquery> and <cfoutput>
Both are "block" commands, which means that a corresponding "slash" command is REQUIRED for both of them.
<cfquery name = "recordsetname" datasource = "filename">
SQL command goes here (see the SQL Intro)
</cfquery>
"recordsetname" is simply the name of a dataset that you specify. It will be used in the <cfoutput> command below. The only rule is that it cannot have spaces in the name. "filename" is the name of the Access database file on the Cold Fusion server (the "I" drive) that is set up by your local Database Administrator (me in this case). For your Project 8, use "sds5_general" as your datasource.
That's it!!!!! Cold Fusion makes the link to the Access database, then executes the SQL commands to retrieve the requried data, then incorporates the returned data into your HTML document as specified by the <cfoutput> command (see below).
<cfoutput query = "recordsetname">
#field1# #field2# #field3# .....
</cfoutput>
The fields of data that you want to have displayed are specified with the "#" (pound sign) surrounding the field names. All fields specified in the <cfoutput> command must have been specified in the SQL statement specified in the <cfquery> command. The "recordsetname" must be the same as in the <cfquery> command above.
<HTML>
<HEAD>
<TITLE>Cold Fusion Example</TITLE>
<cfquery name = "salesinfo" datasource = "sds5_general">
SELECT STATE,CATEGORY,UNITS,NETAMT
FROM ORDERS
WHERE (STATE = 'OR' OR STATE = 'NV' OR STATE = 'CA') AND (NETAMT >= 500)
ORDER BY STATE;
</cfquery>
</HEAD>
<BODY>
<H3 ALIGN=CENTER>List of Sales Data for Oregon, Nevada, and Washington</H3>
<H4 ALIGN=CENTER>Sales Amounts Greater Than or Equal To $500</H4>
<cfoutput query = "salesinfo">
#STATE# #CATEGORY# #NETAMT# <p>
</cfoutput>
<H4 ALIGN=CENTER>End of Sales Data List</H4>
</BODY>
</HTML>
Note the paragraph command at the end of the specification of the fields. This causes each line of data to be displayed on separate lines. Remember, all HTML commands apply within the Cold Fusion commands.
Once you have your "cfm" document created, move it to your "I" drive, then "run" it. By "run" it I mean enter the URL in your browser (Netscape or Explorer) and look at the results. You may have to click on the "Refresh" button to get the data to display. Create this document and give it a try. You need to do this before moving to the next phase of the project. Don't forget that the file type is "cfm".