我收到此错误(请参阅以下错误代码):
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
代码示例:
第1行到第4行如下:
<CFQUERY Name="GetFaxFrequency" datasource="#client.datasource#">
Select * From Fax_Frequency
Order By Fax_Frequency_Id
</CFQUERY>
从以下代码派生的错误代码:
<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> > #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>
答案 0 :(得分:0)
忽略其他一些问题..我猜您使用的是MS Access Unicode数据源,而Password
可能是保留字。如果是这样,请重命名列(首选)或切换到常规<cfquery>
并使用方括号(即[Password]
)对其进行转义。
UPDATE Customer
SET [Password] = <cfqueryparam value="#form.password#" ....>
...
更新:虽然我仍在猜测您的数据库/ dsn,但我可以确认Password
是该驱动程序的保留字。这个带有两个字段的简单测试失败并出现完全相同的错误。删除Password
字段,然后成功。这并不是说它只是 问题......
<cfupdate tableName="Customer" formfields="first_name,password" datasource="#dsn#">