Too few parameters. Expected 1. - Problem with asp/access

K

kbrad

I am using the following code in asp to select some data from an access db.
recSel is defined and set further up my webpage, as is rsUpdate User.
I cannot work out how to get past this error message
Too few parameters. Expected 1.
Can anyone see the problem?


strSQL = "SELECT tblUserDetails.UserRecId, tblUserDetails.UserName, " _
& "tblUserDetails.UserPw, tblUserDetails.UserEmailAddress, " _
& "tblUserDetails.UserFirstName, tblUserDetails.UserSurname, " _
& "tblUserDetails.UserPhoneNo, tblUserDetails.UserCompany " _
& "FROM tblUserDetails" _
& " WHERE tblUserDetails.UserName =" & recSel

rsUpdateUser.Open strSQL, adoCon, adOpenDynamic, adLockOptimistic
 
S

Stuart Palmer

Try and write the strSQL to screen and check it's output, then try nd run
this through your db tool (like access) as a query. This process might point
you in the direction of the problem (Like a field doesn't exist, or is of
the wrong type). As we can't see your db and it's contents it's tough to
tell you, the code itself looks pretty good.

Let us know how you get on.

Stu
 
B

Bob Barrows [MVP]

kbrad said:
I am using the following code in asp to select some data from an
access db. recSel is defined and set further up my webpage, as is
rsUpdate User.
I cannot work out how to get past this error message
Too few parameters. Expected 1.

This always means that a word exists in the query where a field or table
reference should be.
Can anyone see the problem?


strSQL = "SELECT tblUserDetails.UserRecId, tblUserDetails.UserName, "
_ & "tblUserDetails.UserPw, tblUserDetails.UserEmailAddress, " _
& "tblUserDetails.UserFirstName, tblUserDetails.UserSurname, " _
& "tblUserDetails.UserPhoneNo, tblUserDetails.UserCompany " _
& "FROM tblUserDetails" _
& " WHERE tblUserDetails.UserName =" & recSel

You cannot debug this without knowing what the actual sql statement is. The
only way to determine that is to response.write it. Show us the result of

Response.Write strSQL

UserName is probably a character (Text) field so you need to concatenate
delimiters around the filter value:

& " WHERE tblUserDetails.UserName ='" & recSel & "'"

Here are some previous posts I've made dealing with delimiters (and how to
avoid dealing with them):


http://www.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&[email protected]


http://tinyurl.com/jyy0


http://www.google.com/groups?hl=en&...ows&hl=en&lr=&ie=UTF-8&oe=UTF-8&start=10&sa=N


Bob Barrows
 
K

kbrad

Brilliant - so simple when you know how!!

I have another problem, now I'm getting this
Microsoft VBScript runtime error '800a000d'

Type mismatch: 'rsUserUpdate'


It related to this line of code which tries to put a value from the
recordset into a form.
<td><input name="firstname" type="text" maxlength="200" VALUE="<%
response.write rsUserUpdate("UserFirstName") %>"> </td>

Any ideas would be very welcome.
 
B

Bob Barrows [MVP]

It probably contains Null. Do this:

response.write rsUserUpdate("UserFirstName") & ""

Bob Barrows
 
K

kbrad

I don't understand this can you explain what the &"" is for?
I've tried it and get the same error.
 
B

Bob Barrows [MVP]

It's to append an empty string to the Null that was supposedly contained in
the recordset field, which I guess is not the case since you are still
getting the error. Without knowing what's in your recordset i really can't
help. Try looping through your recordset fields with this code to see if you
can see the problem:

for each fld in rsUserUpdate.Fields
Response.Write fld.Name & ": """ & fld.value & """<BR>"
next

Bob Barrows
 
K

kbrad

Oh stupid me!!! It should be rsUpdateUser not rsUserUpdate -problem solved.
Thanks for you help with this and the original problem. Greatly appreciated.
 
A

Aaron [SQL Server MVP]

Oh stupid me!!! It should be rsUpdateUser not rsUserUpdate -problem
solved.

Why not just call it rs? Eliminates this problem...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top