0
我得到這個錯誤(見下文錯誤代碼):ColdFusion的數據庫更新錯誤
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>
我會試試看感謝 – user715461
我可以得到,並添加加刪除列表中的一個客戶端,但不能更新,一旦記錄在DB中 - 所以密碼不是我所知道的問題 - 主要錯誤是第54行: 錯誤執行數據庫查詢。 UPDATE語句中的語法錯誤。 52:\t 53:\t 54:\t \t 55:\t \t 56:\t \t \t選擇*來自客戶 –
user715461
首先,您使用的數據庫類型是什麼?它是MS Access(Unicode DSN)嗎? – Leigh