|
-
Oct 13th, 2009, 08:49 AM
#1
Thread Starter
Member
[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!
-
Oct 13th, 2009, 08:53 AM
#2
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.
-
Oct 13th, 2009, 09:11 AM
#3
Thread Starter
Member
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?
-
Oct 13th, 2009, 09:16 AM
#4
Re: too few parameters, expected 1
 Originally Posted by evaleah
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
-
Oct 13th, 2009, 09:18 AM
#5
Thread Starter
Member
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.....
-
Oct 13th, 2009, 04:02 PM
#6
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.
-
Oct 13th, 2009, 07:19 PM
#7
Thread Starter
Member
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.
-
Oct 14th, 2009, 07:47 AM
#8
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|