66
Developing Web Applications with ColdFusion
4
UPDATE Employees
4
SET Firstname=’#Form.Firstname#’,
4
LastName=’#Form.LastName#’,
4
Department_ID=’#Form.Department_ID#’
4
StartDate=’#Form.StartDate#’>
4
Salary=#Form.Salary#>
WHERE Employee_ID=#Employee_ID#
</CFQUERY>
<H1>Employee Added</H1>
<CFOUTPUT>
You have updated the information for #Form.FirstName# #Form.LastName#
in the Employees database.
</CFOUTPUT>
3.
Save the page. as
updatepage.cfm
.
4.
View
updateform.cfm
in a browser, enter values, and click the Submit button.
5.
The data is updated into the Employees table and the message appears.
Code Review
Deleting Data
Deleting data in a database can be done with a single delete page. The delete page
contains a CFQUERY tag with a SQL delete statement.
To delete one record from a database:
1.
Open the file
updateform.cfm
in Studio.
2.
Modify the file by changing the FORM tag so that it appears as follows:
<FORM ACTION="deletepage.cfm" METHOD="Post">
3.
Save the modified file as
deleteform.cfm
.
4.
Create a new application page in Studio.
Code
Description
<CFQUERY NAME="UpdateEmployee"
DATASOURCE="CompanyInfo">
UPDATE Employees
SET Firstname=’#Form.Firstname#’,
LastName=’#Form.LastName#’,
Department_ID=’#Form.Department_ID#’
StartDate=’#Form.StartDate#’>
Salary=#Form.Salary#>
WHERE Employee_ID=#Employee_ID#
</CFQUERY>
After the SET clause, you must name a table column.
Then, you indicate a constant or expression as the
value for the column.
Be sure to remember the WHERE statement. If you
do not use it, If you do not use it, the SQL UPDATE
statement will apply the new information to every
row in the database.
Содержание COLDFUSION 4.5-DEVELOPING WEB
Страница 1: ...Allaire Corporation Developing Web Applications with ColdFusion ColdFusion 4 5...
Страница 14: ...xiv Developing Web Applications with ColdFusion...
Страница 26: ...xxvi Developing Web Applications with ColdFusion...
Страница 34: ...8 Developing Web Applications with ColdFusion...
Страница 70: ...44 Developing Web Applications with ColdFusion...
Страница 84: ...58 Developing Web Applications with ColdFusion...
Страница 114: ...88 Developing Web Applications with ColdFusion...
Страница 148: ...122 Developing Web Applications with ColdFusion...
Страница 174: ...148 Developing Web Applications with ColdFusion...
Страница 208: ...182 Developing Web Applications with ColdFusion...
Страница 244: ...218 Developing Web Applications with ColdFusion...
Страница 274: ...248 Developing Web Applications with ColdFusion...
Страница 288: ...262 Developing Web Applications with ColdFusion...
Страница 300: ...274 Developing Web Applications with ColdFusion...
Страница 350: ...324 Developing Web Applications with ColdFusion...
Страница 362: ...336 Developing Web Applications with ColdFusion...