Updates existing records in data sources.
<cfupdate dataSource = "ds_name" dbType = "type" dbServer = "dbms" dbName = "database name" connectString = "connection string" tableName = "table_name" tableOwner = "name" tableQualifier = "qualifier" username = "username" password = "password" provider = "COMProvider" providerDSN = "datasource" formFields = "field_names">
cfinsert, cfprocparam, cfprocresult, cfquery, cfqueryparam, cfstoredproc, cftransaction
<!--- This example shows the use of cfupdate to change
records in a data source --->
<!--- if course_ID has been passed to this form, then
perform the update on that record in the data source --->
<cfif IsDefined("form.course_ID") is "True">
<cfupdate dataSource = "cfsnippets"
tableName = "courses" formFields = "course_ID,Course_Num,Descript">
</cfif>
<!--- perform a query to reflect any updated information
if course_ID is passed through a url, we are selecting a
record to update ... select only that record with the
WHERE clause
--->
<cfquery name = "GetCourseInfo" dataSource = "cfsnippets">
SELECT Course_Num, Course_ID, Descript
FROM Courses
<cfif IsDefined("url.course_ID") is True>
WHERE Course_ID = #url.course_ID#
</cfif>
ORDER by Course_Num
</cfquery>
<html>
<head>
<title>cfupdate Example</title>
</head>
<body bgcolor = silver>
<H3>cfupdate Example</H3>
<!--- if we are updating a record, don't show
the entire list --->
<cfif NOT IsDefined("url.course_ID")>
<P><H3><a href = "cfupdate.cfm">Show Entire List</A></H3>
<form method = "POST" action = "cfupdate.cfm">
<H3>You can alter the contents of this
record, and then click "submit" to use
cfupdate and alter the database</H3>
<P>Course Number <input type = "Text" name = "number"
value = "<cfoutput>#GetCourseInfo.Course_Num#</cfoutput>">
<P>Course Description<BR>
<TEXTAREA name = "Descript" COLS = "40" ROWS = "5">
<cfoutput>#GetCourseInfo.Descript#</cfoutput>
</TEXTAREA>
<input type = "hidden" name = "course_id"
value = "<cfoutput>#GetCourseInfo.Course_ID#</cfoutput>">
<P><input type = "Submit" name = "">
</form>
<cfelse>
<!--- Show the entire record set in cftable form --->
<cftable query = "GetCourseInfo" HTMLTable>
<cfcol text = "<a href = 'cfupdate.cfm?course_ID = #course_ID#'>Edit Me</a>"
width = 10 header = "Edit<br>this Entry">
<cfcol text = "#Course_Num#" width = "4" header = "Course Number">
<cfcol text = "#Descript#" width = 100 header = "Course Description">
</cftable>
</cfif>
</body>
</html>