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

session variables in sql statement

Status
Not open for further replies.

frogggg

Programmer
Jan 17, 2002
182
US
what's wrong with this code?

rsDisplay.setSQLText("SELECT JobInfo.* " _
& "FROM JobInfo " _
& "WHERE Location=" & session("Location"))

I'm getting this error:

Too few parameters. Expected 2.

When I put the single quotes in I get data type mismatch, because a number is being passed.

Is there something I don't know about session variables in sql statements?
 
You might want to throw in some debug code to ensure that Session("Location") actually has a value. If the client you are hitting it with doesn't have Session level cookies enabled then the server won't "hold" that Session variable and it will be empty everytime you hit it from a new page.
 
I'm guessing your using as access database.
When you get this sort of sql error is
can often mean you have an unquoted string.
Try

rsDisplay.setSQLText("SELECT JobInfo.* " _
& "FROM JobInfo " _
& "WHERE Location='" & session("Location") & "'")

note the single quotes

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top