Need help with SQL statement

milehigh

Senior member
Nov 1, 1999
951
0
76
set strCats = Request.QueryString("cats")
sqlCats = "SELECT * FROM subCats where ID = strCats "

ID is an autonumber primary key in an Access DB.
I've tried it as
sqlCats = "SELECT * FROM subCats where ID = strCats "
sqlCats = "SELECT * FROM subCats where ID = '" & strCats &"'"

It works if I enter as....
sqlCats = "SELECT * FROM subCats where ID = 2"

I tried strCats=Cint(Request.QueryString("cats") as well and that didn't work either.

Any suggestions??
 

KLin

Lifer
Feb 29, 2000
29,556
163
106
You're trying to compare a number to the string "cats". You need to use the the field that contains the text "cats" in the where clause.

So something like sqlCats = "SELECT * from subCats where Description = '" & strCats & "'"

EDIT: Those are single quotes in the where clause BTW to qualify it as text ;).
 

milehigh

Senior member
Nov 1, 1999
951
0
76
After my hosting company 'suggested' I do my troubleshooting locally I finally get it figured out.

Thanks for the reply!!