Updating Data
3
4
5
Reviewing the code
The following table describes the highlighted code and its function:
Code
<cfquery name="UpdateEmployee"
</cfquery>
<h1>Employee Updated</h1>
<cfoutput>
You have updated the information for #Form.FirstName#
#Form.LastName# in the Employees database.
</cfoutput>
Save the page.
View updateform.cfm in a browser by specifying the page URL and an Employee
ID, for example, http://localhost/myapps/updateform.cfm?Emp_ID=3. Enter
new values in any of the fields, and click Submit.
The data is updated into the Employee table and the message displays.
datasource="CompanyInfo">
UPDATE Employee
SET FirstName = '#Form.Firstname#',
LastName = '#Form.LastName#',
Dept_ID = '#Form.Dept_ID#',
StartDate = '#Form.StartDate#',
Salary = '#Form.Salary#'
WHERE Emp_ID = #Form.Emp_ID#
Description
Update the record in the
database that matches the
primary key on the form,
(Emp_ID). Update all fields in the
record with names that match the
names of controls on the form.
Because #From.Emp_ID# is
numeric, you do not enclose it in
quotes.
111
Need help?
Do you have a question about the COLDFUSION 5-DEVELOPING and is the answer not in the manual?
Questions and answers