Results 1 to 8 of 8

Thread: [RESOLVED] too few parameters, expected 1

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2001
    Location
    St. Louis, Missouri
    Posts
    49

    Resolved [RESOLVED] too few parameters, expected 1

    I have a VB6 app running against an Access2000 database. I have the following bit of code to generate a SQL statement:
    Code:
    strSQL = "select distinct QCType, LowValue, HighValue from " & strSpecsTable
        strSQL = strSQL + " where ShortName = """ & FieldName & """"
    When this is run it produces a perfect SQL statement. It looks exactly like what I am looking for. The value coming up in the Immediate window is:
    Code:
    select distinct QCType, LowValue, HighValue from tblDataSpecs_v1_0 where ShortName = "CRITERIA"
    I copy and paste this directly into the Access DB and it runs beautifully. I have checked my connection string, that is all perfect and running against the correct database. Still, I am getting "Too few parameters. Expected 1" each and every time I allow the program to execute this statement. What am I missing?

    HELP!!!! Thanks!

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: too few parameters, expected 1

    Thread moved to 'Database Development' forum (the 'VB6' forum is only meant for questions which don't fit in more specific forums)

    The most likely cause is your use of " around the text value, whereas you should be using ' instead.

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2001
    Location
    St. Louis, Missouri
    Posts
    49

    Re: too few parameters, expected 1

    This is Access. The ' character would be for SQL or Oracle. Access encloses text values with " marks.

    Any other ideas?

  4. #4
    PowerPoster abhijit's Avatar
    Join Date
    Jun 1999
    Location
    Chit Chat Forum.
    Posts
    3,228

    Question Re: too few parameters, expected 1

    Quote Originally Posted by evaleah View Post
    This is Access. The ' character would be for SQL or Oracle. Access encloses text values with " marks.

    Any other ideas?
    Access can also use ' Single Quotes.

    Have you at least given it a shot?
    Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
    save a blobFileStreamDataTable To Text Filemy blog

  5. #5

    Thread Starter
    Member
    Join Date
    Feb 2001
    Location
    St. Louis, Missouri
    Posts
    49

    Re: too few parameters, expected 1

    Honestly, I had not and it worked. Weird. I still wonder why all my other SQL statements with " marks work and this one didn't but I guess I will never know.....

  6. #6
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: too few parameters, expected 1

    An important point is that you are not actually using Access, you are just using an .mdb file (which for obvious reasons is known as an Access database) via Jet or ACE.

    There are some differences between the SQL interpreter used in Access itself and the ones used in Jet/ACE.


    I'm not entirely sure how Jet/ACE treat values inside " marks, but I recommend changing them all to ' if you can - because it might be treating those items as field names rather than values, and thus doing the wrong thing.

  7. #7

    Thread Starter
    Member
    Join Date
    Feb 2001
    Location
    St. Louis, Missouri
    Posts
    49

    Re: too few parameters, expected 1

    It occurred to me later that everything I had done recently was in DAO which didn't work with ' marks. Since I am more of a SQL Server programmer than an Access one I had had all kinds of issues with those marks about a week ago. Oh well... Thanks again for the tip and your patience.

  8. #8
    PowerPoster abhijit's Avatar
    Join Date
    Jun 1999
    Location
    Chit Chat Forum.
    Posts
    3,228

    Re: too few parameters, expected 1

    Please mark this thread as "RESOLVED", if you don't have any more issues.
    Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
    save a blobFileStreamDataTable To Text Filemy blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width