Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Login Question

Status
Not open for further replies.

andy570

Technical User
Jan 5, 2004
40
US
I have a login page with the following query:
<cfquery name="GetUser" datasource="#DataSource#">
SELECT UserID, Username, Password, Company, FName, LName, AuthLevel
FROM Users
WHERE UserName='#FORM.UserLogin#' AND Password='#FORM.UserPassword#'
</cfquery>

When I attempt to login I receive the following error:

Error Executing Database Query.


18 : SELECT UserID, Username, Password, Company, FName, LName, AuthLevel
19 : FROM Users
20 : WHERE UserName='#FORM.UserLogin#' AND Password='#FORM.UserPassword#'

Thanks for any assistance.






 
In the error message it states:

Too few parameters. Expected 2.
 
I don't see anything wrong with the query, we're going to need more details about the error message before we can help.



Hope This Helps!

Ecobb

&quot;My work is a game, a very serious game.&quot; - M.C. Escher
 
Hi mate,

I've seen this error a few times recently with Access DBs. The error normally means one of the coloumn names does not exist. Check your database and make sure they all exist and there are no typos.

Hope this helps

Wullie


The pessimist complains about the wind. The optimist expects it to change. The leader adjusts the sails. - John Maxwell
 
here is the entire error message:

Error Occurred While Processing Request
Error Executing Database Query.
Macromedia SequeLink JDBC Driver ODBC Socket MicrosoftODBC Microsoft Access Driver Too few parameters. Expected 2.

The error occurred in D:\ line 20
Called from D:\ line 10
Called from D:\ line 20
Called from D:\ line 10

18 : SELECT UserID, Username, Password, Company, FName, LName, AuthLevel
19 : FROM Users
20 : WHERE UserName='#FORM.UserLogin#' AND Password='#FORM.UserPassword#'
21 : </cfquery>
22 :



--------------------------------------------------------------------------------

SQL SELECT UserID, Username, Password, Company, FName, LName, AuthLevel FROM Users WHERE UserName='xxxx' AND Password='xxxxxxx'
DATASOURCE software
VENDORERRORCODE -3010
SQLSTATE 07002

Please try the following:
Check the ColdFusion

Application.cfm code:

<CFSET Datasource = "software">
<cfapplication
Name="zipscript"
Sessionmanagement="yes">
<cfinclude template="forceuserlogin.cfm">

forceuserlogin.cfm code:

<cflogin>


<cfif not(IsDefined("Form.UserLogin") AND IsDefined("Form.UserPassword"))>
<cfinclude template="ZipScript.cfm">
<cfabort>

<cfelse>

<cfquery name="GetUser" datasource="#DataSource#">
SELECT UserID, Username, Password, Company, FName, LName, AuthLevel
FROM Users
WHERE UserName='#FORM.UserLogin#' AND Password='#FORM.UserPassword#'
</cfquery>


<cfif GetUser.RecordCount EQ 1>

<cfloginuser
Name="#GetUser.UserID#, #GetUser.FName#, #GetUser.LName#, #GetUser.Company#"
Password="#Form.UserPassword#"
Roles="#GetUser.AuthLevel#">


<cfelse>
<script>
alert("You must login to access this area!");
</script>
<cfinclude template="ZipScript.cfm">
<cfabort>
</cfif>
</cfif>
</cflogin>

zipscript.cfm form code:

<cfform action="#CGI.SCRIPT_NAME#" name="UserLoginForm" method="Post">
<!---Make the UserLogin and UserPassword fields required--->
<input type="hidden" name="UserLogin_required">
<input type="hidden" name="UserPassword_required">

<table border="0" align="center">
<tr bgcolor="#000000">
<th colspan="2"><font color="#FFFFFF">Please Log In</font></th>
</tr>
<tr>
<th><font color="#FFFFFF">UserName</font>:</th>
<td>
<!---Text field for "User Name"--->
<cfinput Type="text"
Name="UserLogin"
Size="20"
Value=""
Maxlength="100"
Required="yes"
Message="Please type your Username"> </td>
</tr>
<tr>
<th><font color="#FFFFFF">Password:</font></th>
<td>
<!---Text field for "Password"---> <cfinput Type="text"
Name="UserPassword"
Size="20"
Value=""
Maxlength="100"
Required="yes"
Message="Please type your Password">

<input type="submit" value="Enter"> </td></tr></table><div align="center"></div></cfform>

Thank you for the assistance. (I believe I have included all the code referred to.)
 
D'oh....Access DB Field name not right - got it. Thanks for the help!
 
Also another thing to consider (thanks Wullie for this one) access dosnt like double quotes in where querys just something to bear in mind, i had them in mine and it made it choke, removed them it was fine
This is a problem with access 2000 i think, as access 2002(XP) is ok with ".
Just A Thing to Remember!

The way web design should be
 
For sure is a problem in the table.
Maybe that one column is not EXACTLY the name of the field you query.
It only seems to your eyes, because it is a long time you see it and you do not pay attention to them.

Try this. Query the table one field per time, and discover the field that is not accepted.

example:

<cfquery name="GetUser" datasource="#DataSource#">
SELECT UserID FROM Users
WHERE UserName='#FORM.UserLogin#' AND Password='#FORM.UserPassword#'
</cfquery>
<CFABORT>

<cfquery name="GetUser" datasource="#DataSource#">
SELECT Company
FROM Users
WHERE UserName='#FORM.UserLogin#' AND Password='#FORM.UserPassword#'
</cfquery>
<CFABORT>

and so on.
If it doesn't work, try an optimization of the database within access 2000.
Error 2 is for sure a mismatch from queried fields with existing fields.

GUBA
 
Thank you for all your help....got it working.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top