all groups > sql server (alternate) > october 2003 >
You're in the

sql server (alternate)

group:

CF / SQL Server syntax error HELP


CF / SQL Server syntax error HELP Phil Powell
10/14/2003 8:37:57 PM
sql server (alternate): I am not sure why this is producing a SQL Server related error, but w/o
having an instance of SQL Server on my machine to verify anything further,
can you all help me with this?

<!--- validate() --->
<cffunction name="validate" access="remote" returnType="numeric">
<cfargument name="username" required="yes" type="string" />
<cfargument name="password" required="yes" type="string" />

<cfquery name="validate" datasource="#request.dsn#">
SELECT userID
FROM User
WHERE username = '#UCase(username)#'
AND password = '#UCase(password)#'
</cfquery>

<cfif validate.RecordCount EQ 0>
<cfquery name="log" datasource="#request.dsn#">
UPDATE User
SET lastLoggedIn = #createOdbcDate(now())#
WHERE userId = #validate.userID#
</cfquery>
<cfreturn validate.userID />
<cfelse>
<cfreturn 0 />
</cfif>
</cffunction>

Sorry that's all I can honestly provide, other than the error being on the
line with <cfif validate.RecordCount>

Phil

Re: CF / SQL Server syntax error HELP charliek
10/14/2003 11:00:11 PM
On Tue, 14 Oct 2003 20:37:57 -0400, "Phil Powell" <soazine@erols.com>
[quoted text, click to view]

OK you want to select the userid that has a username of #username# and
a password of #password#.

[quoted text, click to view]

Now if no user is found, update the users last login date. This code
will throw an error because validate.userID will not be defined.
Because you are trying to update a user only when no user is found.
It should not throw a database error but rather validate.userid is not
defined and that will throw an error. replace the above if statement
with the one below, and if a problem still remains please provide the
error messages given.

<cfif validate.recordCount GT 0>

and now every thing should work fine.

[quoted text, click to view]

Also you can download a 120 trial of MS SQL server and if you are
running windows 2000+ you can run it.

Re: CF / SQL Server syntax error HELP Adam Haskell
10/16/2003 3:15:49 PM
[quoted text, click to view]

Slight correction....Even if the query returns 0 resutlts validate.userID
will be defined it will just be blank.
The error from SQL is probably saying "Incorrect syntax near '='."
The cause of the problem is still the same...your if statement should be GT
or NEQ 0.
Side note bad form calling a table user....that is an SQL reserve word I
thought...

Adam H

[quoted text, click to view]

AddThis Social Bookmark Button