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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error: Too few parameters Expected 1

Status
Not open for further replies.

juls3

Programmer
Jan 14, 2003
7
US
I'm trying to run a select query in vb 6 and get the error "too few parameters, expected 1". I believe it has to do with the syntax of the script, but I can't figure out what it is.

Here's my code:

strcnn = "Provider=MSDASQL.1;Persist Security info=False;Data Source=dBASE Files;Initial Catalog=" & test_dir

Set cnn = New ADODB.Connection
cnn.Open strcnn

TypeSave = rsttable2!Type
Set rsttable = cnn.Execute("select * from oldnew where left(new,4) = '" & TypeSave & "'")

Oldnew is a dbase database and new is a legitimate column in oldnew.dbf. Any ideas??
 
Maybe the word "new" is a reserved word. Try putting brackets around it in your SQL statement.

Set rsttable = cnn.Execute("select * from oldnew where left([new],4) = '" & TypeSave & "'")
 
I've tried that. Forgot to add this this will run correctly on Window98 but not its now loaded on windows 2000 server and will not run. If I just use "select * from oldnew" it works but anything more than that, it gives me the error.
 
Are you using the same database when you're trying it on both machines? I'd look at that Left function next. Perhaps the database doesn't know that one.
 
Yes. Its the exact same database on both machines. I've tried it with the 'left' not there.
set rsttable = cnn.execute("select * from oldnew where new = 'HOME'")
It gives me the same error.
 
It seems to me that I get that error when I try to reference a field that doesn't exist. You said they do exist...
I'm out of ideas. Good luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top