ColdFusion database update error
I get this error (see code below error):
Error Executing Database Query.
Syntax error in UPDATE statement.
The error occurred in
C:\Sites\laroccaseafood\www.laroccaseafood.com\wwwroot\Admin\AdminCustomer.cfm: line 54
Called from C:\Sites\laroccaseafood\www.laroccaseafood.com\wwwroot\Admin\AdminCustomer.cfm: line 53
Called from C:\Sites\laroccaseafood\www.laroccaseafood.com\wwwroot\Admin\AdminCustomer.cfm: line 1
Called from C:\Sites\laroccaseafood\www.laroccaseafood.com\wwwroot\Admin\AdminCustomer.cfm: line 54
Called from C:\Sites\laroccaseafood\www.laroccaseafood.com\wwwroot\Admin\AdminCustomer.cfm: line 53
Called from C:\Sites\laroccaseafood\www.laroccaseafood.com\wwwroot\Admin\AdminCustomer.cfm: line 1
52 : </CFCASE>
53 : <CFCASE VALUE="update">
54 : <CFUPDATE TABLENAME="Customer" DATASOURCE="#client.datasource#">
55 : <CFQUERY NAME="GetCustomer" DATASOURCE="#client.datasource#">
56 : Select * From Customer
CODE EXAMPLE:
Line 1 to 4 are as follows:
<CFQUERY Name="GetFaxFrequency" datasource="#client.datasource#">
Select * From Fax_Frequency
Order By Fax_Frequency_Id
</CFQUERY>
Error code derived from this code below:
<TR><TD VALIGN="top">
<CFSET mode_list = "add,edit,update,invalid">
<CFIF ListContainsNoCase(mode_list, url.mode)>
<CFIF url.mode is "invalid">
<TABLE ALIGN="center" CELLPADDING="2" CELLSPACING="0" BGCOLOR="Red">
<TR><TH COLSPAN="4">Current Customer Record</TH></TR>
<CFELSE>
<TABLE ALIGN="center" CELLPADDING="2" CELLSPACING="0">
<TR><TH COLSPAN="4">Edit Customer</TH></TR>
</CFIF>
<CFFORM ACTION="AdminCustomer.cfm?mode=update" METHOD="post" NAME="addCustomer">
<CFOUTPUT>
<TR><TD>First Name</TD><TD>
<CFINPUT TYPE="Text" SIZE="20" VALUE="#GetCustomer.First_Name#" MAXLENGTH="50" NAME="First_Name" REQUIRED="Yes" MESSAGE="Enter First Name">
</TD><TD>Last Name</TD><TD>
<CFINPUT TYPE="Text" SIZE="20" VALUE="#GetCustomer.Last_Name#" MAXLENGTH="50" NAME="Last_Name" REQUIRED="Yes" MESSAGE="Enter Last Name">
</TD></TR>
<TR><TD>Company</TD><TD>
<CFINPUT TYPE="Text" SIZE="20" VALUE="#GetCustomer.Company_Name#" MAXLENGTH="50" NAME="Company_Name" REQUIRED="Yes" MESSAGE="Enter Company Name">
</TD><TD>Fax ( 4153446789 )</TD><TD>
<CFINPUT TYPE="Text" SIZE="20" VALUE="#GetCustomer.Fax_Number#" MAXLENGTH="11" NAME="Fax_Number" REQUIRED="Yes" VALIDATE="integer" RANGE="0000000000,19999999999" MESSAGE="Enter a proper fax number ( 14153768888 )">
</TD></TR>
<TR><TD>User Name</TD><TD>
<CFINPUT TYPE="Text" SIZE="20" VALUE="#GetCustomer.User_Name#" MAXLENGTH="50" NAME="User_Name" REQUIRED="Yes" MESSAGE="Enter User Name">
</TD><TD>Password</TD><TD>
<CFINPUT TYPE="Text" SIZE="20" VALUE="#GetCustomer.Password#" MAXLENGTH="50" NAME="Password" REQUIRED="Yes" MESSAGE="Enter Password">
</TD></TR>
</CFOUTPUT>
<TR><TD>User Type</TD><TD>
<SELECT NAME="User_Level">
<CFLOOP LIST="Administrator,Salesperson,Customer" INDEX="User_Level">
<CFOUTPUT>
<option VALUE="#User_Level#" <cfif #User_Level# is #GetCustomer.User_Level#>Selected</CFIF> >#User_Level#
</CFOUTPUT>
</CFLOOP>
</SELECT>
</TD><TD>Account Status</TD>
<TD>Enabled
<INPUT TYPE="Radio" NAME="Customer_Status" VALUE="1" <cfif #GetCustomer.Customer_Status# is 1>CHECKED</cfif> >
Disabled
<INPUT TYPE="Radio" NAME="Customer_Status" VALUE="0" <cfif #GetCustomer.Customer_Status# is 0>CHECKED</cfif> >
</TD></TR>
<TR><TD NOWRAP><BR>
Here Now <BR><FONT CLASS="normaltext">
<CFOUTPUT QUERY="GetFaxFrequency">
<INPUT TYPE="Checkbox" NAME="here_now" VALUE="#Fax_Frequency_Id#" <CFIF #listfind(#GetCustomer.here_now#,#Fax_Frequency_Id#)# is not 0>Checked</CFIF> > #Fax_Frequency_Desc#<BR>
</CFOUTPUT>
</TD><TD NOWRAP><BR>
Coming Soon<BR><FONT CLASS="normaltext">
<CFOUTPUT QUERY="GetFaxFrequency">
<INPUT TYPE="Checkbox" NAME="coming_soon" VALUE="#Fax_Frequency_Id#" <CFIF #listfind(#GetCustomer.coming_soon#,#Fax_Frequency_Id#)# is not 0>Checked</CFIF> > #Fax_Frequency_Desc#<BR>
</CFOUTPUT>
</TD><TD NOWRAP><BR>
All Items<BR><FONT CLASS="normaltext">
<CFOUTPUT QUERY="GetFaxFrequency">
<INPUT TYPE="Checkbox" NAME="all_items" VALUE="#Fax_Frequency_Id#" <CFIF #listfind(#GetCustomer.all_items#,#Fax_Frequency_Id#)# is not 0>Checked</CFIF> > #Fax_Frequency_Desc#<BR>
</CFOUTPUT>
</TD><TD NOWRAP><BR>
Hot List<BR><FONT CLASS="normaltext">
<CFOUTPUT QUERY="GetFaxFrequency">
<INPUT TYPE="Checkbox" NAME="hot_list" VALUE="#Fax_Frequency_Id#" <CFIF #listfind(#GetCustomer.hot_list#,#Fax_Frequency_Id#)# is not 0>Checked</CFIF> > #Fax_Frequency_Desc#<BR>
</CFOUTPUT>
</TD></TR>
<TR><TD><BR></TD><TD><BR></TD><TD><BR></TD><TD><BR></TD></TR>
<CFOUTPUT>
<TR><TD COLSPAN="4">
<INPUT TYPE="Hidden" VALUE="#GetCustomer.Customer_Id#" NAME="Customer_Id">
<CFIF url.mode is NOT "invalid">
<INPUT TYPE="Submit" VALUE=" update ">
</CFIF>
</TD><TR>
</CFOUTPUT>
</CFFORM>
</TABLE>
</CFIF>
</TD></TR>
<TR><TD ALIGN="center" VALIGN="top">
<TABLE ALIGN="center" CELLPADDING="2" CELLSPACING="0">
<CFFORM ACTION="AdminCustomer.cfm?mode=Add" METHOD="post" NAME="addCustomer">
<CFIF url.mode is "invalid">
<TR><TH NOWRAP ALIGN="center">
<FONT CLASS="errortext">The User Name submitted already exists!
</TH></TR>
<CFSET User_Name = "">
<CFELSE>
<CFSCRIPT>
User_Name = "";
Password = "";
First_Name = "";
Last_Name = "";
Company_Name = "";
First_Name = "";
Fax_Number = "";
Hot_list = "";
Coming_Soon = "";
Here_Now = "";
All_Items = "";
</CFSCRIPT>
</CFIF>
<TR><TH>Add Customer</TH></TR>
<TR><TD>
<TABLE ALIGN="center" CELLPADDING="2">
<CFOUTPUT>
<TR><TD>First Name</TD>
<TD>
<CFINPUT TYPE="Text" SIZE="20" VALUE="#First_Name#" MAXLENGTH="50" NAME="First_Name" REQUIRED="Yes" MESSAGE="Enter First Name">
</TD>
<TD>Last Name</TD>
<TD>
<CFINPUT TYPE="Text" SIZE="20" VALUE="#Last_Name#" MAXLENGTH="50" NAME="Last_Name" REQUIRED="Yes" MESSAGE="Enter Last Name">
</TD></TR>
<TR><TD>Company</TD>
<TD>
<CFINPUT TYPE="Text" SIZE="20" VALUE="#Company_Name#" MAXLENGTH="50" NAME="Company_Name" REQUIRED="Yes" MESSAGE="Enter Company Name">
</TD>
<TD>Fax ( 14153446789 )</TD>
<TD>
<CFINPUT TYPE="Text" SIZE="20" VALUE="#Fax_Number#" MAXLENGTH="11" NAME="Fax_Number" REQUIRED="Yes" VALIDATE="integer" RANGE="0000000000,19999999999" MESSAGE="Enter a proper fax number ( 14153768888 )">
</TD></TR>
<TR><TD>User Name</TD>
<TD>
<CFINPUT TYPE="Text" SIZE="20" VALUE="#User_Name#" MAXLENGTH="50" NAME="User_Name" REQUIRED="Yes" MESSAGE="Enter User Name">
</TD>
<TD>Password</TD>
<TD>
<CFINPUT TYPE="Text" SIZE="20" VALUE="#Password#" MAXLENGTH="50" NAME="Password" REQUIRED="Yes" MESSAGE="Enter Password">
</TD></TR>
</CFOUTPUT>
<TR><TD NOWRAP><BR>
Here Now <BR><FONT CLASS="normaltext">
<CFOUTPUT QUERY="GetFaxFrequency">
<INPUT TYPE="Checkbox" NAME="here_now" VALUE="#Fax_Frequency_Id#" <CFIF #listfind(#here_now#, #Fax_Frequency_Id#)# is not 0>Checked</CFIF> >&开发者_如何学Python;nbsp;#Fax_Frequency_Desc#<BR>
</CFOUTPUT>
</TD><TD NOWRAP><BR>
Coming Soon<BR><FONT CLASS="normaltext">
<CFOUTPUT QUERY="GetFaxFrequency">
<INPUT TYPE="Checkbox" NAME="coming_soon" VALUE="#Fax_Frequency_Id#" <CFIF #listfind(#coming_soon#, #Fax_Frequency_Id#)# is not 0>Checked</CFIF> > #Fax_Frequency_Desc#<BR>
</CFOUTPUT>
</TD><TD NOWRAP><BR>
All Items<BR><FONT CLASS="normaltext">
<CFOUTPUT QUERY="GetFaxFrequency">
<INPUT TYPE="Checkbox" NAME="all_items" VALUE="#Fax_Frequency_Id#" <CFIF #listfind(#all_items#, #Fax_Frequency_Id#)# is not 0>Checked</CFIF> > #Fax_Frequency_Desc#<BR>
</CFOUTPUT>
</TD><TD NOWRAP><BR>
Hot List<BR><FONT CLASS="normaltext">
<CFOUTPUT QUERY="GetFaxFrequency">
<INPUT TYPE="Checkbox" NAME="hot_list" VALUE="#Fax_Frequency_Id#" <CFIF #listfind(#hot_list#, #Fax_Frequency_Id#)# is not 0>Checked</CFIF> > #Fax_Frequency_Desc#<BR>
</CFOUTPUT>
</TD></TR>
<TR><TD><BR></TD><TD><BR></TD><TD><BR></TD><TD><BR></TD></TR>
<TR><TD>User Type</TD>
<TD>
<SELECT NAME="User_Level">
<CFLOOP LIST="Administrator,Salesperson,Customer" INDEX="User_Level">
<CFOUTPUT>
<option VALUE="#User_Level#" <cfif #User_Level# is "Customer">Selected</CFIF> >#User_Level#
</CFOUTPUT>
</CFLOOP>
</SELECT>
</TD><TD>
<INPUT TYPE="Submit" VALUE=" Add Customer">
</TD><TR>
</CFFORM>
</TABLE>
</TD></TR>
</TABLE>
</TD></TR>
Ignoring a few other issues .. my guess is you are using an MS Access Unicode datasource and that Password
may be a reserved word. If so, either rename the column (preferable) or switch to a regular <cfquery>
and escape it with square brackets ie [Password]
.
UPDATE Customer
SET [Password] = <cfqueryparam value="#form.password#" ....>
...
Update: While I am still guessing about your database/dsn, I can confirm that Password
is a reserved word with that driver. This simple test with two fields fails with the exact same error. Remove the Password
field and it succeeds. That is not to say it is the only issue ...
<cfupdate tableName="Customer" formfields="first_name,password" datasource="#dsn#">
精彩评论