Skip to main content
Inspiring
April 21, 2008
Question

Update Error Without any Reason.

  • April 21, 2008
  • 1 reply
  • 339 views
I have a Code which is i think is fine, Irun it give Syntax error in Update Statement:

The code I am Trying to do is:


<CFIF NOT isDefined ("URL.clientUserLookupID")>
<CFLOCATION url="list.cfm" addtoken=no>
</CFIF>

<CFQUERY name=clientUserInfo datasource="#Application.data#">
SELECT tblclientUserLookup.clientUserLookupID, tblclientUserLookup.ClientID, tblUsers.username, tblUsers.password, tblUsers.UserEmail, tblUsers.UserID
FROM tblclientUserLookup, tblUsers
WHERE tblclientUserLookup.clientUserLookupID = #URL.clientUserLookupID#
AND tblUsers.UserID = tblclientUserLookup.UserID
</CFQUERY>

<CFQUERY name=AttachedSearchesInfo datasource="#Application.data#">
SELECT tblSearches.SearchID
FROM tblclientUserSearchLookup, tblSearches
WHERE tblclientUserSearchLookup.clientUserLookupID = #URL.clientUserLookupID#
AND tblclientUserSearchLookup.SearchID = tblSearches.SearchID
</CFQUERY>
<CFSET AttachedSearchList = "">
<CFLOOP query=AttachedSearchesInfo>
<CFSET AttachedSearchList = ListAppend("#AttachedSearchList#", "#SearchID#")>
</CFLOOP>

<CFQUERY name=ClientInfo datasource="#Application.data#">
SELECT Name
FROM tblClients
WHERE ClientID = #clientUserInfo.ClientID#
</CFQUERY>

<CFQUERY name=SearchInfo datasource="#Application.data#">
SELECT *
FROM tblSearches
WHERE ClientID = #clientUserInfo.ClientID#
</CFQUERY>

<CFINCLUDE template="../../header.cfm">

<CFOUTPUT>
<p><b>client EXTRANET ACCOUNT : Modify '#ClientInfo.Name#' ACCOUNT</b></p>
</CFOUTPUT>

<CFFORM action="data/update.cfm" method=post>
<CFOUTPUT query=clientUserInfo>
<table>
<tr>
<td align=right class=AdminField>
Username
</td>
<td>
<CFINPUT type=text name="username" value="#username#" required=yes message="You must enter a Username.">
</td>
</tr>
<tr>
<td align=right class=AdminField>
Password
</td>
<td>
<CFINPUT type=text name="password" value="#password#" required=yes message="You must enter a Password.">
</td>
</tr>
<tr>
<td align=right class=AdminField>
Account Email Address
</td>
<td>
<CFINPUT type=text value="#useremail#" name="email">
</td>
</tr>
<tr>
<td align=right class=AdminField valign=top>
Linked Searches
</td>
<td>
<CFSET SizeVar = 10>
<CFSELECT name=SearchesToAttach multiple=yes size="#sizeVar#">
<CFLOOP query=SearchInfo>
<CFIF ListFind("#AttachedSearchList#", "#SearchID#")>
<OPTION value=#SearchID# selected>#Title#</OPTION>
<CFELSE>
<OPTION value=#SearchID#>#Title#</OPTION>
</CFIF>
</CFLOOP>
</CFSELECT><br>
hold down ctrl for multiple
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>
<INPUT type="hidden" name="clientUserLookupID" value="#clientUserLookupID#">
<INPUT type="hidden" name="UserID" value="#UserID#">
<INPUT type="submit" value="Update Account">
</td>
</tr>
</table>
</CFOUTPUT>
</CFFORM>



<CFINCLUDE template="../../footer.cfm">

The above is the file where we have a form and when i click the update submit button:

The code of that page is below:


<CFIF NOT IsDefined("Form.UserID") OR NOT IsDefined("Form.ClientUserLookupID")>
<CFLOCATION url="../list.cfm" addtoken=no>
</CFIF>

<CFQUERY name="exists" datasource="#Application.data#">
SELECT *
FROM tblUsers
WHERE username = '#Form.username#'
AND UserID <> #Form.UserID#
</CFQUERY>

<CFIF exists.recordcount GT 0>
<CFINCLUDE template="../cannotadd.cfm">
<CFABORT>
</CFIF>
<!---<cfdump var="#form#"><cfabort>--->
<CFTRANSACTION>
<cfquery datasource="RainesDataBase">
UPDATE tblUsers
SET Username=<cfif IsDefined("FORM.username") AND #FORM.username# NEQ "">
<cfqueryparam value="#FORM.username#" cfsqltype="cf_sql_clob" maxlength="50">
<cfelse>
''
</cfif>
, Password=<cfif IsDefined("FORM.password") AND #FORM.password# NEQ "">
<cfqueryparam value="#FORM.password#" cfsqltype="cf_sql_clob" maxlength="50">
<cfelse>
''
</cfif>
, UserEmail=<cfif IsDefined("FORM.email") AND #FORM.email# NEQ "">
<cfqueryparam value="#FORM.email#" cfsqltype="cf_sql_clob" maxlength="50">
<cfelse>
''
</cfif>
WHERE UserID=<cfqueryparam value="#FORM.UserID#" cfsqltype="cf_sql_numeric">
</cfquery>
<!---
<CFQUERY name=updateUser datasource="#Application.data#">
UPDATE tblUsers
SET Username = '#Form.Username#',
Password = '#Form.Password#',
UserEmail = '#Form.email#'
WHERE UserID = #Form.UserID#
</CFQUERY>
--->
<CFQUERY name="deleteClientUserSearchLookups" datasource="#Application.data#">
DELETE
FROM tblClientUserSearchLookup
WHERE ClientUserLookupID = #Form.ClientUserLookupID#
</CFQUERY>

<CFIF isDefined("Form.searchesToAttach")>
<CFLOOP list="#Form.searchesToAttach#" index=index>
<CFQUERY name=insertClientUserSearchLookup datasource="#Application.data#">
INSERT INTO tblClientUserSearchLookup (ClientUserLookupID, SearchID)
VALUES (#Form.ClientUserLookupID#, #index#)
</CFQUERY>
</CFLOOP>
</CFIF>

</CFTRANSACTION>

<CFLOCATION url="../list.cfm" addtoken=no>

But this is not working as it is showing this below error as:

he web site you are accessing has experienced an unexpected error.
Please contact the website administrator.

The following information is meant for the website developer for debugging purposes.
Error Occurred While Processing Request
Error Executing Database Query.
Syntax error in UPDATE statement.

The error occurred in C:\Inetpub\wwwroot\ConsultantTrack_OldFTP\Admin\users\clients\data\update.cfm: line 19

17 : <!---<cfdump var="#form#"><cfabort>--->
18 : <CFTRANSACTION>
19 : <cfupdate datasource="#Application.data#" tablename="tblUsers" formfields="username,password,UserEmail,userid">
20 : <!---<cfquery datasource="RainesDataBase">
21 : UPDATE tblUsers

SQLSTATE  
SQL update tblUsers set username= (param 1) ,password= (param 2) ,UserEmail= (param 3) where UserID= (param 4)
VENDORERRORCODE 3092
DATASOURCE RainesDataBase
Resources:
    This topic has been closed for replies.

    1 reply

    Inspiring
    April 21, 2008
    Could be the datatypes in your cfqueryparam tags. As a minimum, use integer for the userid one.

    Or it could be a reserved problem with "password"