Exercise 4: Updating A Sql Row Using The Cfupdate Tag - MACROMEDIA COLFUSION MX 7-GETTING STARTED BUILDING COLDFUSION MX Getting Started

Building coldfusion mx applications
Table of Contents

Advertisement

To verify that the trip was saved, open the tripsearchform.cfm page in the my_app directory in
3.
your browser.
In the Trip Search page, in the Trip Location drop-down list, select the Begins With option,
4.
and enter the value Nor in the text box.
Click Search.
5.
The TripResults page appears.
Click NH White Mountains to display the details of the trip you just added. Verify that all the
6.
fields were saved correctly.
For more information about adding data to a database using the
MX Developer's Guide.

Exercise 4: Updating a SQL row using the cfupdate tag

To update an existing SQL row, ColdFusion offers a simple approach through the use of the
tag. Like the
cfupdate
attributes to specify where the data is to be inserted. The tag also has a
identify which fields are to insert. The
form fields to insert. If this attribute is not specified, all the fields in the form are included in the
operation.
All the fields of the tripedit.cfm page have corresponding columns in the Trips table, so you can
omit the
FormFields
field is passed from the Trip Edit page, the
executed. The following example uses the
attribute:
<cfif not isdefined("form.tripID")>
<cfinsert datasource="CompassTravel" tablename="Trips">
<cflocation url="tripdetail.cfm">
<cfelse>
<cfupdate datasource="CompassTravel" tablename="Trips">
<cflocation url="tripdetail.cfm?ID=#Form.tripID#">
</cfif>
tag, the
cfinsert
cfupdate
formfields
attribute for both the
cfupdate
cfupdate

Exercise 4: Updating a SQL row using the cfupdate tag

cfinsert
tag has
datasource
attribute specifies a comma-separated list of
and
cfinsert
cfupdate
tag is used; otherwise the
and
cfinsert
tag, see ColdFusion
and
tablename
attribute to
formfields
tags. If the
form
tripID
cfinsert
tags without the
formfields
tag is
137

Advertisement

Table of Contents
loading

This manual is also suitable for:

Colfusion mx 7 - installing and using coldfusion mx

Table of Contents