|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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> |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
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! |
|
#4
|
|||
|
|||
|
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. |
|
#5
|
|||
|
|||
|
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 |
|
#6
|
|||
|
|||
|
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 |
|
#7
|
|||
|
|||
|
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 |
|
#8
|
|||
|
|||
|
Good for you - congratulations. so I take it then, you don't need anymore help?
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > ASP Development > retrieve records |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|