ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 23rd, 2003, 07:37 PM
adammendoza adammendoza is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: California
Posts: 8 adammendoza User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question retrieve records

I'm trying to display some records from access but I don't know why is not showing.

I can do a log in fine but no records are shown even though they are there.

how do I use request.QueryString?

I want to use the myname varible to retrieve the records.

<%
Option Explicit

dim dbname
dim myname
dim conntemp, cnpath, sqltemp, objRS

dbname="database.mdb"
myname=request.QueryString("myname")
set conntemp=server.createobject("adodb.connection")
cnpath="DBQ=" & server.mappath(dbname)
conntemp.Open "DRIVER={Microsoft Access Driver (*.mdb)}; " & cnpath
sqltemp="select * from tblCases where hosp='"
sqltemp=sqltemp & myname & "'"
set objRS=conntemp.execute(SQLTemp)

'-----------------------------------------------------------
' START OF CODE TO PUT AT THE TOP OF A PAGE NEEDING
' PASSWORD PROTECTING
'-----------------------------------------------------------

'Do not load/display this page if the user is not logged-in
'Check this by checking the Session LoggedIn variable
if Session("LoggedIn") <> "yes" then

Session("Message") = "You must log in before viewing that page!"
response.redirect "login.1.asp"

end if

%>
<HTML>
<HEAD>
<TITLE>destinatin.3.asp</TITLE>
</HEAD>

<BODY BGCOLOR = "#000099" TEXT="#ffffff" LINK="#000000" VLINK="#00ffff" ALINK="#00ffff">
<center>
<h1>Login Successful!</h1>
</center>
<p>
<%
'if objRS.State = 1 then objRS.Close
sqltemp="select * from tblCases where hosp='"
sqltemp=sqltemp & myname & "'"
set objRS=conntemp.execute(SQLTemp)

while not objRS.EOF
Response.Write "<li><b>" & objRS("ext") & "</b></li>"
objRS.MoveNext
wend
%>
<p>
<center><a href="logout.asp">Logout</a></center>
</BODY>
</HTML>

Reply With Quote
  #2  
Old January 23rd, 2003, 09:25 PM
aspnewbie aspnewbie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Great White North
Posts: 361 aspnewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 50 sec
Reputation Power: 16
Send a message via MSN to aspnewbie
You use request.querystring when you are passing info in the url either with a href or a form with a method="get". You use request.form when you are using a form with a method="post"

If you do a response.write myname after your request.querystring, does it actually return anything?

Can you provide the code in which you are inputting myname (i.e., have you got it as a textbox in a form on another page?) That may assist in pinpointing the problem.

Also you seem to have the same select statement twice on the same page? or am I missing something?

You might want to be consistent (although it may not make a difference) in your use of variable (you have sqltemp and SQLTemp).

Lastly, you could use a "like" statement to try to match the string.

Reply With Quote
  #3  
Old January 23rd, 2003, 11:35 PM
adammendoza adammendoza is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: California
Posts: 8 adammendoza User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question

Thanks for the help. okay, I made the myname variable = ACM which is one of the IDs and the sql query ran fine. but how do I get the variable from the previous page?

yes the request.querystring is to ge stuff from url. The request.form ("tctvardd") is to get txt form a form in the previous page.

how can I get a variable from a previous page?

What I did is.
page 1, has form to grab userid and pw and is passed to page 2 via request.form redirects to page 2

page 2, validates login and converts userid txt into variable myname then it redirects to page 3 which can be any securepage.

page 3, I'm running a query and I need to get myname. so Basically the user never saw page 2. How do I get the variable myname from page 2 to page 3.?

thanks!

Reply With Quote
  #4  
Old January 24th, 2003, 09:31 AM
aspnewbie aspnewbie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Great White North
Posts: 361 aspnewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 50 sec
Reputation Power: 16
Send a message via MSN to aspnewbie
If you are using an id as opposed to a string your syntax for your select statement will differ.

In that case it will be

sqltemp="select * from tblCases where hosp=" & myname

I think it might be easier if you just upload what you have so I can see all the code together.

Also, have you tried the tutorial on this site called "Hey I remember you"? It's for the purposes of creating a members only section. It probably does everything that you're looking to accomplish.

Reply With Quote
  #5  
Old January 24th, 2003, 11:49 AM
adammendoza adammendoza is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: California
Posts: 8 adammendoza User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
The problem is to get the variable from the previous page. I want to use the ID to do the search that way they don't look at the records for other members.

I can send the files so you can look at it.

thanks
Adam
Attached Files
File Type: zip login1.zip (26.0 KB, 710 views)

Reply With Quote
  #6  
Old January 24th, 2003, 01:09 PM
adammendoza adammendoza is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: California
Posts: 8 adammendoza User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I was reading on another site and I found out that to use a variable in more than one .asp page I need to declare it as a session variable or application variable.

so That's where I'm off to. Learning ho to make the session variable. Looks like the Application could be more complicated

Reply With Quote
  #7  
Old January 24th, 2003, 01:32 PM
adammendoza adammendoza is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: California
Posts: 8 adammendoza User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Whohoo!

I got it.

using a Sesssion("myname")

instead of just myname.

thx. for the help

other shources

http://www.w3schools.com/asp/asp_variables.asp

http://istdb.ist210.ist.psu.edu/labs/ASP_Session.htm

Reply With Quote
  #8  
Old January 24th, 2003, 02:27 PM
aspnewbie aspnewbie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Great White North
Posts: 361 aspnewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 50 sec
Reputation Power: 16
Send a message via MSN to aspnewbie
Good for you - congratulations. so I take it then, you don't need anymore help?

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > retrieve records


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap