User Guide

Table Of Contents
475
CHAPTER 21
Updating Your Database
This chapter describes how to use ColdFusion to insert, update, and delete information in a
database.
Contents
About updating your database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
Inserting data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
Updating data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 480
Deleting data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487
About updating your database
ColdFusion was originally developed as a way to readily interact with databases. You can quickly
insert, update, and delete the contents of your database by using ColdFusion forms, which are
typically a pair of pages. One page displays the form with which your end user will enter values;
the other page performs the action (insert, update or delete).
Depending on the extent and type of data manipulation, you can use CFML with or without
SQL commands. If you use SQL commands, ColdFusion requires a minimal amount of SQL
knowledge.
Inserting data
You usually use two application pages to insert data into a database:
An insert form
An insert action page
You can create an insert form with standard HTML form tags or with
cfform tags (see “Creating
custom forms with the cfform tag” on page 631). When the user submits the form, form variables
are passed to a ColdFusion action page that performs an insert operation (and whatever else is
called for) on the specified data source. The insert action page can contain either a
cfinsert tag
or a
cfquery tag with a SQL INSERT statement. The insert action page should also contain a
confirmation message for the end user.