Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

too few parameters, expected 1

Status
Not open for further replies.

evaleah

Programmer
Mar 18, 2003
252
US
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:
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!
 
Turns out if I altered the statement to use ' instead of " it works.
 

Did you try this:
Code:
strSQL = "select distinct QCType, LowValue, HighValue from " & strSpecsTable
strSQL = strSQL + " where ShortName = " & Chr(34) & FieldName & Chr(34)

Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top