Whatever message this page gives is out now! Go check it out!

cfupdate

Last update:
May 18, 2026
Note:
This tag is unsupported in  CFFiddle .

Description

Updates records in a data source from data in a ColdFusion form or form Scope.

Category

Syntax

dataSource = "ds_name"
tableName = "table_name"
formFields = "field_names"
password = "password"
tableOwner = "name"
tableQualifier = "qualifier"
username = "username">
Note:
You can specify this tag's attributes in an attributeCollection attribute whose value is a structure. Specify the structure name in the attributeCollection attribute and use the tag's attribute names as structure keys.

See also

cfinsert cfprocparam cfprocresult cfquery cfqueryparam cfstoredproc cftransactionCreating an update action page with cfupdate in the Developing ColdFusion Applications.

History

ColdFusion 11: Removed the attributes - connectString, dbName, dbServer, dbtype, provider, and providerDSN.
ColdFusion 10: Added the clientInfo attribute.
ColdFusion MX: Deprecated the connectString, dbName, dbServer,  dbtype , provider, and  providerDSN  attributes. They do not work, and might cause an error, in releases later than ColdFusion 5.

Attributes

AttributeReq/OptDefaultDescription
clientInfo
Optional
Structure containing properties of the client to be set on the database connection.
dataSource
Optional
Name of the data source that contains the table.
tableName
Required
Name of table to update.
  • For Oracle drivers, must be uppercase.
  • For Sybase driver, case sensitive; must be in same case as used when the table was created.
formFields
Optional
(all on form, except keys)
Comma-delimited list of form fields to update. If a form field is not matched by a column name in the database, ColdFusion throws an error. The formFields list must include the database table primary key field, which must be present in the form. It can be hidden.
password
Optional
Overrides the password value specified in ODBC setup.
tableOwner
Optional
For data sources that support table ownership (for example, SQL Server, Oracle, Sybase SQL Anywhere), the table owner.
tableQualifier
Optional
For data sources that support table qualifiers. The purpose of table qualifiers is as follows:
  • SQL Server and Oracle: name of the database that contains the table
  • Intersolv dBASE driver: directory of DBF files
username
Optional
Overrides username value specified in ODBC setup.

Example

<cfif isDefined("form.phone")>
<cfupdate datasource="cfdocexamples" tablename="EMPLOYEES">
</cfif>

<cfquery name="empTable" datasource="cfdocexamples">
SELECT * FROM EMPLOYEES
</cfquery>

<!--- This code shows the contents of the employee table and allows you to choose a row for updating. --->
<table border="1">
<cfoutput query="empTable">
<tr>
<td>#firstName#</td>
<td>#lastName#</td>
<td>#phone#</td>
<td><a href="cfupdate.cfm?id=#emp_id#">Edit</a></td>
</tr>
</cfoutput>
</table>

<cfif isDefined("url.id")>
<cfquery name="phoneQuery" datasource="cfdocexamples">
SELECT * FROM employees WHERE emp_id=#url.id#
</cfquery>
<!--- This code displays the row to edit for update. --->
<cfoutput query="phoneQuery">
<form action="cfupdate.cfm" method="post">
#phoneQuery.firstName# #phoneQuery.lastName#
<input name="phone" type="text" value="#phone#" size="12">
<input type="submit" value="Update">
<input name="emp_id" type="hidden" value="#emp_id#">
<!--- The emp_id is passed as a hidden field to be used as a primary
key in the CFUPDATE. --->
</form>
</cfoutput>
</cfif>
Note:
The cfupdate tag internally uses parameterized queries.

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page