Print Page | Close Window

SQL Too Few parameters

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=6214
Printed Date: 31 March 2026 at 8:42am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: SQL Too Few parameters
Posted By: twooly
Subject: SQL Too Few parameters
Date Posted: 06 October 2003 at 1:07pm

Ok I am trying to create a function where people can register for an account on my server.  But first I want to check and see if the username already exists.  Here is the error I am getting and was hoping someone could help out.

Microsoft OLE DB Provider for ODBC Drivers error '80040e10'

[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.

/register.asp, line 80

 

Here is my code with line 80 noted

 

<%
If Request.querystring("mode") = "add" then

'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("site.mdb")

strUserName = Request.Form("txtUserName")
strUserPass = Request.Form("txtUserPass")


'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "INSERT INTO tblUsers (username, password) VALUES('" & strUserName & "', '" & strUserPass & "')"
strSQLCheck = "SELECT username from tblUsers WHERE username = " & strUserName


Set rsNewUser = adoCon.Execute(strSQLCheck)  --line 80

IF rsNewUser.EOF then 
 Set rsNewUser = adoCon.Execute(strSQL)
 Response.Redirect"start.asp"
End If

'Reset server objects

Set rsNewUser = Nothing
Set adoCon = Nothing
Response.Wrtie ("Username is already taken.  Please choose another one.")

 

End If
%>




Replies:
Posted By: MorningZ
Date Posted: 06 October 2003 at 2:30pm

more than likely one of the two fields has multiple form fields named the same....

to check this, take the line

strSQL = "INSERT INTO tblUsers (username, password) VALUES('" & strUserName & "', '" & strUserPass & "')"

and replace it for this temporarily... run the page again, check the database to see if there are "*"'s in the inserted values

strSQL = "INSERT INTO tblUsers (username, password) VALUES('" & Replace(strUserName,",","*") & "', '" & Replace(strUserPass,",","*") & "')"

of course as well, you could always write out the SQL statement and look at it

strSQL = "INSERT INTO tblUsers (username, password) VALUES('" & strUserName & "', '" & strUserPass & "')"
Response.Write(strSQL)
Response.End

strSQLCheck = "SELECT username from tblUsers WHERE username = " & strUserName



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: michael
Date Posted: 06 October 2003 at 2:30pm
strSQLCheck = "SELECT username from tblUsers WHERE username = '" & strUserName & "'"

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: michael
Date Posted: 06 October 2003 at 2:32pm
MorningZ, he is executing the strSQLCheck one which does not have the insert statement, he forgot to quote the string.

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: twooly
Date Posted: 06 October 2003 at 2:36pm

michael that was the answer.  Thanks for the help

 

--Todd




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net