Using Custom Query in the Database Results Wizard

G

Guest

I have an asp page in my website(userpage.asp), which will be displayed after a user is logged into the site. According to the user id I want to display a set of linkss. For this purpose I used the custom query option in the database results wizard. The query I typed is as below;

SELECT title,link FROM links WHERE 'Semester= & semester'

The database that I'm accessing has tables called, students and links. After a valid user is logged in, a session variable will be set to store the semester value of that user, from the student table. I want to use this session variable value in the above query to get a set of links from the links table, where the semester value is matching.

But the above query keeps on giving problems. Please help me with this.

Thanks
Weavedev
 
T

Thomas A. Rowe

Try:

Dim Semester
Semester = Session("Semester")


SELECT title, link FROM links WHERE Semester= '" & semester & "' "



--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, WebCircle, MS KB Quick Links, etc.
==============================================


Weavedev said:
I have an asp page in my website(userpage.asp), which will be displayed after a user is logged
into the site. According to the user id I want to display a set of linkss. For this purpose I used
the custom query option in the database results wizard. The query I typed is as below;
SELECT title,link FROM links WHERE 'Semester= & semester'

The database that I'm accessing has tables called, students and links. After a valid user is
logged in, a session variable will be set to store the semester value of that user, from the student
table. I want to use this session variable value in the above query to get a set of links from the
links table, where the semester value is matching.
 
J

Jon Spivey

Hi,
It's a bit difficult to use session variables in the DRW. The only way I've
found to do is to put code like this at the top of your page

<%
if request.querystring("semester") = "" then
response.redirect request.servervaraibles("SCRIPT_NAME") & "?semester=" &
session("semester")
end if
%>
and then type a custom query
select * from table where semester = '::semester::'

--
Cheers,
Jon
Microsoft MVP - FP

Weavedev said:
I have an asp page in my website(userpage.asp), which will be displayed
after a user is logged into the site. According to the user id I want to
display a set of linkss. For this purpose I used the custom query option in
the database results wizard. The query I typed is as below;
SELECT title,link FROM links WHERE 'Semester= & semester'

The database that I'm accessing has tables called, students and links.
After a valid user is logged in, a session variable will be set to store the
semester value of that user, from the student table. I want to use this
session variable value in the above query to get a set of links from the
links table, where the semester value is matching.
 
K

Kevin Spencer

It should also be noted that when you use Session, you are using a volatile
memory space. That is, Sessions time out after an interval, and values
stored in Session are lost if the user doesn't send a new Request within
that interval. For that reason, you should always handle the eventuality
that a Session will be lost.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
G

Guest

Hi John,
I tried your method but it returned the following error:

Error Type:
Microsoft VBScript runtime (0x800A01B6)
Object doesn't support this property or method: 'Response.servervaraibles'
/mysite/userpage1.asp, line 86
 
G

Guest

Hi Thomas,
I tried the method you have suggested. When I include the query as you have mentioned in the custom query dialog box and verify it, it gets verified. But when the page is viewed the following error message is mentioned in the location where the database results was meant to be.

Database Results Wizard Error
The operation failed. If this continues, please contact your server administrator.

Thanks & Rgds
Weavedev
 
G

Guest

Hi,
I tried this method and it still gives an error;

Database Results Wizard Error
The operation failed. If this continues, please contact your server administrator.

Can you please explain to me what is the "SCRIPT_NAME" in the first script block in your answer means. And in which page should I include this first script block you have given, is it in the page where the Database Results are diplayed or in the page where the user is authenticated?

Thank You again
Weavedev
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top