Deleting Data - Adobe 38043740 - ColdFusion Standard - Mac Development Manual

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Accessing and Using Data
Creating an update action page with cfquery
For more complicated updates, you can use a SQL UPDATE statement in a
The SQL UPDATE statement is more flexible for complicated updates.
The following procedure assumes that you have created the update_action.cfm page as described in
update action page with
cfupdate" on page 424.
In update_action.cfm, replace the
1
<html>
<head>
<title>Update Employee</title>
</head>
<body>
<cfif not isdefined("Form.Contract")>
<cfset form.contract = "No">
<cfelse>
<cfset form.contract = "Yes">
</cfif>
<!--- cfquery requires date formatting when retrieving from
Access. Use the left function when setting StartDate to trim
the ".0" from the date when it first appears from the
Access database --->
<cfquery name="UpdateEmployee" datasource="cfdocexamples">
UPDATE Employee
SET FirstName = '#Form.Firstname#',
LastName = '#Form.LastName#',
Dept_ID = #Form.Dept_ID#,
StartDate = '#left(Form.StartDate,19)#',
Salary = #Form.Salary#
WHERE Emp_ID = #Form.Emp_ID#
</cfquery>
<h1>Employee Updated</h1>
<cfoutput>
You have updated the information for
#Form.FirstName# #Form.LastName#
in the employee database.
</cfoutput>
</body>
</html>
Save the page.
2
View update_form.cfm in your web browser by specifying the page URL and an Employee ID; for example, enter
3
the following: http://localhost/myapps/update_form.cfm?Emp_ID=3
4
Enter new values in any of the fields, and click Update Information.
ColdFusion updates the record in the Employee table with your new values and displays a confirmation message.
When the
tag retrieves date information from a Microsoft Access database, it displays the date and time with
cfquery
tenths of seconds, as follows:

Deleting data

You use a
tag with a SQL DELETE statement to delete data from a database. ColdFusion has no
cfquery
tag with the following highlighted
cfupdate
Last updated 1/20/2012
tag instead of a
cfquery
cfupdate
"Creating an
code:
cfquery
cfdelete
426
tag.
tag.

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents