• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Step 6. Updating, Inserting, and Deletin... > Example 6.2: Updating Database Infor...

Example 6.2: Updating Database Information

Let’s create the action page for our form.

1.
Open your text editor and enter the code in Listing 6.2 or open the completed EmployeeUpdate.cfm file from the CompletedFiles\Examples\Step06 folder.
Listing 6.2. EmployeeUpdate.cfm Code

<!---
File:             EmployeeUpdate.cfm 
Description:      Updates employee record in database 
Author: 
Created: 
---> 
<!--- use SQL to update employee record ---> 
<CFQUERY NAME="qUpdateEmployee" DATASOURCE="Staff"> 
      UPDATE     Employees 
      SET        FirstName='#Trim(FORM.FirstName)#', 
                 LastName='#Trim(FORM.LastName)#', 
                 DepartmentID=#Val(FORM.DepartmentID)#, 
                 Title='#Trim(FORM.Title)#', 
                 Email='#Trim(FORM.Email)#', 
                 Extension=#Val(FORM.Extension)#, 
                 DateHired=#CreateODBCDate(FORM.DateHired)# 
      WHERE      EmployeeID=#FORM.EmployeeID# 
</CFQUERY> 

<HTML> 
  <HEAD> 
      <TITLE>Employee Details Updated</TITLE> 
  </HEAD> 
  <BODY> 
       <CFOUTPUT> 
       <!--- provide feedback for successful update ---> 
       <P><B>Successfully Updated The Employee Record For:<BR> 
       #FORM.FirstName# #FORM.LastName#</B></P> 
       <A HREF="EmployeeSearch.cfm"> Return to employee search</A> 
       </CFOUTPUT> 
  </BODY> 
</HTML>

					  



2.
Save the file as EmployeeUpdate.cfm in your Examples\Step06 folder.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint