Contents > Getting Started Building ColdFusion MX Applications > Lesson 6: Adding and Updating SQL Data > Completing the Trip Maintenance application > Writing code to save new trips to the database Exercise: insert trip data using cfinsert PreviousNext

Exercise: insert trip data using cfinsert

In this exercise, you change the approach the action page uses to insert the data into the database. You will replace the SQL INSERT statement with the cfinsert tag.

To add data using cfinsert:

  1. Open tripeditaction.cfm from the my_app directory in your editor and do the following:
    1. Remove the entire AddTrip cfquery that you added in the last exercise (from the beginning <cfquery name ="AddTrip" datasource="CompassTravel"> tag to the </cfquery> end tag).
    2. Add the following cfinsert tag to insert data into the trips table in the same location as the code that you just deleted:
         <cfinsert datasource="CompassTravel" tablename="TRIPS"> 
      
  2. Save the page and test it by opening the tripedit.cfm page in your browser.
  3. Follow step 4 through step 9 in the previous exercise to verify this approach to inserting new trips.

For more information about adding data to a database using the cfinsert tag, see Developing ColdFusion MX Applications.


Contents > Getting Started Building ColdFusion MX Applications > Lesson 6: Adding and Updating SQL Data > Completing the Trip Maintenance application > Writing code to save new trips to the database Exercise: insert trip data using cfinsert PreviousNext

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.