BackUp LevelNext

Creating an Insert Page with CFINSERT

The CFINSERT tag is the easiest way to handle simple inserts from either a CFFORM or an HTML form.

In most cases, the optional attributes are not needed. The TABLEOWNER and TABLEQUALIFIER attributes are rarely necessary but are provided for compatibility with ODBC drivers that require you to specify a table owner and/or table qualifier. Neither of these fields needs to be specified for the Microsoft ODBC Desktop Drivers bundled with ColdFusion.

ODBC drivers that require table owners and/or qualifiers to be specified include all SQL Server and Oracle drivers, as well as all Intersolv Q&E drivers.

CFINSERT datasource

The ODBC data source is named "Employees DB" and the table you want to insert data into is named "Employees." Given this information, the CFINSERT tag would be included in your page as follows:

<CFINSERT DATASOURCE="Employee DB" TABLENAME="Employees">

Example: HTML form page

The following example illustrates an HTML form with the CFINSERT tag.

<!-- HTML form to input data -->
<HTML>
<HEAD>
    <TITLE>Input Form</TITLE>
</HEAD>
<BODY>

<FORM ACTION="EmployeeInsert.cfm" 
    METHOD="Post">
<PRE>
First Name: <INPUT TYPE="text" 
    NAME="FirstName">
Last Name: <INPUT TYPE="text" 
    NAME="LastName">
Phone: <INPUT TYPE="text" 
    NAME="Phone">
<INPUT TYPE="Submit" 
    VALUE="Insert Information">
</PRE>
</FORM>

</BODY>
</HTML>

Example: CFINSERT action page

<!--- Inserts the data from the the HTML Form --->
<CFINSERT DATASOURCE="Employee DB" 
    TABLENAME="Employees">

<HTML>
<HEAD>
    <TITLE>Input Form</TITLE>
</HEAD>
<BODY>

<CENTER><H2>Thank You!</H2></CENTER>
<HR>
<P>Thank you for entering your data into 
our database - please visit our site often!</P>
<HR>

</BODY>
</HTML>

BackUp LevelNext

allaire

AllaireDoc@allaire.com
Copyright © 1998, Allaire Corporation. All rights reserved.