Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - SQL Too Few parameters
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

SQL Too Few parameters

 Post Reply Post Reply
Author
twooly View Drop Down
Groupie
Groupie


Joined: 24 September 2003
Status: Offline
Points: 64
Post Options Post Options   Thanks (0) Thanks(0)   Quote twooly Quote  Post ReplyReply Direct Link To This Post Topic: SQL Too Few parameters
    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
%>

Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post 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



Edited by MorningZ
Contribute to the working anarchy we fondly call the Internet
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 06 October 2003 at 2:30pm
strSQLCheck = "SELECT username from tblUsers WHERE username = '" & strUserName & "'"
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
twooly View Drop Down
Groupie
Groupie


Joined: 24 September 2003
Status: Offline
Points: 64
Post Options Post Options   Thanks (0) Thanks(0)   Quote twooly Quote  Post ReplyReply Direct Link To This Post Posted: 06 October 2003 at 2:36pm

michael that was the answer.  Thanks for the help

 

--Todd

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.