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

use of session var as Parameter in Recordset definition

Status
Not open for further replies.

kusi

Instructor
Oct 26, 2001
5
0
0
CH
Hi
I have a recordset in page A. By clicking on one dataset, a key, say "spec", is stored in a session variable and page B opens. On Page B, the Recordset should use the session variable as parameter in the SQL-Where statement. I am using ultradev and asp-javascript.

When I have the statment ... WHERE such=V_spec, with the parameter definition V_spec / 'spec' / Session("sesspec") i have an ODBC-Error.

Whats wrong here?

thanks Markus
 
Depending on the data type in the database you might have to provide quotes around the value.

For example:

Select * from Customer where CustomerID=6

works if CustomerID is a numeric data type. However if it's character based then you have to do somthing like this:

Select * from Customer where CustomerID='6'

You might have to do something like this in your code:

Select * from Customer where CustomerID='" + Session("sesspec") + "'"

If you still can't get it to work, try hard coding the value in the select statement to be sure you don't have something wrong in the SQL. Once it passes with the hardcoded value, then add the session variable information.

Hope that helps,
Snaggs
tribesaddict@swbell.net
Life can only be understood backwards; but it must be lived forwards.
 
Why use it in the session variable. You should be able to just pass it in the querystring, but....

It appears that the problem is as listed above. Try a response.write, response.end command. It will print the SQL on teh screen. The try it directly against the database. It will give you a more accurate error to use to determine what you need to do.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top