Updating Data; Creating An Update Form - MACROMEDIA COLDFUSION 5-DEVELOPING Develop Manual

Table of Contents

Advertisement

106
Reviewing the code
The following table describes the highlighted code and its function:
Code
<cfquery name="AddEmployee"
</cfquery>

Updating Data

You usually use two application pages to update data in a database:
You can create an update form with
form calls an update action page, which can contain either a
cfquery
contain a message for the end user that reports on the update completion.

Creating an update form

An update form is similar to an insert form, but there are two key differences:
The easiest way to designate the primary key in an update form is to include a hidden
input field with the value of the primary key for the record you want to update. The
hidden field indicates to ColdFusion which record to update.
datasource="CompanyInfo">
INSERT INTO Employee
VALUES ('#Form.Emp_ID#',
'#Form.FirstName#',
'#Form.LastName#',
'#Form.Dept_ID#',
'#Form.StartDate#',
'#Form.Salary#',
'#Form.Contract#')
An update form
An update action page
tag with a SQL UPDATE statement. The update action page should also
An update form contains a reference to the primary key of the record that is being
updated.
A primary key is a field or combination of fields in a database table that uniquely
identifies each record in the table. For example, in a table of employee names
and addresses, only the Emp_ID would be unique to each record.
An update form is usually populated with existing record data because the form's
purpose is to update data.
Chapter 7 Updating Your Database
Description
Use a
cfquery
into the Employee table of the
CompanyInfo Database. Specify each
form field to be added. Because the form
and database field names are identical,
you do not have to specify the database
field names in the query.
tags or HTML form tags. The update
cfform
tag to insert a new row
tag or a
cfupdate

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COLDFUSION 5-DEVELOPING and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Coldfusion 5

Table of Contents