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

Discussion in 'ASP General' started by kbrad, Sep 29, 2004.

  1. kbrad

    kbrad Guest

    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
    kbrad, Sep 29, 2004
    #1
    1. Advertising

  2. 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

    "kbrad" <> wrote in message
    news:...
    > 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
    Stuart Palmer, Sep 29, 2004
    #2
    1. Advertising

  3. kbrad wrote:
    > 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&selm=


    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


    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
    Bob Barrows [MVP], Sep 29, 2004
    #3
  4. kbrad

    kbrad Guest

    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.


    "Bob Barrows [MVP]" wrote:

    > kbrad wrote:
    > > 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&selm=
    >
    >
    > 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
    >
    >
    > --
    > Microsoft MVP -- ASP/ASP.NET
    > Please reply to the newsgroup. The email account listed in my From
    > header is my spam trap, so I don't check it very often. You will get a
    > quicker response by posting to the newsgroup.
    >
    >
    >
    kbrad, Sep 29, 2004
    #4
  5. It probably contains Null. Do this:

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

    Bob Barrows
    kbrad wrote:
    > 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>
    >


    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
    Bob Barrows [MVP], Sep 29, 2004
    #5
  6. kbrad

    kbrad Guest

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

    "Bob Barrows [MVP]" wrote:

    > It probably contains Null. Do this:
    >
    > response.write rsUserUpdate("UserFirstName") & ""
    >
    > Bob Barrows
    > kbrad wrote:
    > > 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>
    > >

    >
    > --
    > Microsoft MVP -- ASP/ASP.NET
    > Please reply to the newsgroup. The email account listed in my From
    > header is my spam trap, so I don't check it very often. You will get a
    > quicker response by posting to the newsgroup.
    >
    >
    >
    kbrad, Sep 29, 2004
    #6
  7. 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
    kbrad wrote:
    > I don't understand this can you explain what the &"" is for?
    > I've tried it and get the same error.
    >
    > "Bob Barrows [MVP]" wrote:
    >
    >> It probably contains Null. Do this:
    >>
    >> response.write rsUserUpdate("UserFirstName") & ""
    >>
    >> Bob Barrows
    >> kbrad wrote:
    >>> 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>
    >>>

    >>
    >> --
    >> Microsoft MVP -- ASP/ASP.NET
    >> Please reply to the newsgroup. The email account listed in my From
    >> header is my spam trap, so I don't check it very often. You will get
    >> a quicker response by posting to the newsgroup.


    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
    Bob Barrows [MVP], Sep 29, 2004
    #7
  8. kbrad

    kbrad Guest

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

    "Bob Barrows [MVP]" wrote:

    > 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
    > kbrad wrote:
    > > I don't understand this can you explain what the &"" is for?
    > > I've tried it and get the same error.
    > >
    > > "Bob Barrows [MVP]" wrote:
    > >
    > >> It probably contains Null. Do this:
    > >>
    > >> response.write rsUserUpdate("UserFirstName") & ""
    > >>
    > >> Bob Barrows
    > >> kbrad wrote:
    > >>> 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>
    > >>>
    > >>
    > >> --
    > >> Microsoft MVP -- ASP/ASP.NET
    > >> Please reply to the newsgroup. The email account listed in my From
    > >> header is my spam trap, so I don't check it very often. You will get
    > >> a quicker response by posting to the newsgroup.

    >
    > --
    > Microsoft MVP -- ASP/ASP.NET
    > Please reply to the newsgroup. The email account listed in my From
    > header is my spam trap, so I don't check it very often. You will get a
    > quicker response by posting to the newsgroup.
    >
    >
    >
    kbrad, Sep 29, 2004
    #8
  9. > Oh stupid me!!! It should be rsUpdateUser not rsUserUpdate -problem
    solved.

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

    --
    http://www.aspfaq.com/
    (Reverse address to reply.)
    Aaron [SQL Server MVP], Sep 29, 2004
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Aaron B.
    Replies:
    2
    Views:
    6,491
    Erich Reimberg N.
    Nov 23, 2004
  2. geletine

    Too few parameters. Expected 2

    geletine, May 21, 2006, in forum: Java
    Replies:
    3
    Views:
    7,788
    geletine
    May 22, 2006
  3. Miranda
    Replies:
    6
    Views:
    302
    Bob Barrows
    Nov 29, 2003
  4. DVan

    Too few parameters. Expected 1.

    DVan, Oct 20, 2004, in forum: ASP General
    Replies:
    9
    Views:
    157
    Aaron [SQL Server MVP]
    Oct 20, 2004
  5. isaac2004

    Too few parameters. Expected 1.

    isaac2004, Feb 19, 2006, in forum: ASP General
    Replies:
    2
    Views:
    143
    Paxton
    Feb 19, 2006
Loading...

Share This Page