Re: Session variables

by "Steve Cost" <scost(at)neo.rr.com>

 Date:  Sat, 23 Dec 2000 23:31:15 -0500
 To:  "Susan Walsh" <susan(at)equilibriumdesign.com>,
"Cyanide _7" <leo7278(at)hotmail.com>,
<hwg-languages(at)hwg.org>
 References:  equilibriumdesign
  todo: View Thread, Original
Susan,
Michael G. had very good suggestions.  I response.write the heck out of
things while debugg .. er, testing.
Another idea: if customer ID is numeric, then you do not want the extra '
(single quote) in the SQL select parameter.  Take it out and try it. I have
made this mistake a number of times.  If not sure if customer ID is string
or integer, do a response.write varType(customer ID) and find out.
Also, but this is a style comment ... your variable names are so long it
makes it a little more difficult to see what you are doing in your code. Not
a big deal, of course.
HTH,
--
Steve C
www.ReadersOpinions.com

----- Original Message -----
From: "Susan Walsh" <susan(at)equilibriumdesign.com>
To: "Cyanide _7" <leo7278(at)hotmail.com>; <hwg-languages(at)hwg.org>
Sent: Saturday, December 23, 2000 6:17 PM
Subject: RE: Session variables


| For some reason, I can't get the recordset from the Customer database to
| filter with the session variable (the customer ID).
|
| I am getting this error after login:
|
| ADODB.Field error '800a0bcd'
|
| Either BOF or EOF is True, or the current record has been deleted; the
| operation requested by the application requires a current record.
|
| /PH/purchase.asp, line 78
|
| (this is where the page starts to read information from the db).
|
|
| Here is what is on the login page:
|
| <%
| Dim rsLoginPswd__strCustomerID
| rsLoginPswd__strCustomerID = "xyz"
| if(Request.Form("CustomerID") <> "") then rsLoginPswd__strCustomerID =
| Request.Form("CustomerID")
|
| Dim rsLoginPswd__strPIN
| rsLoginPswd__strPIN = "zx9edhf7c"
| if(Request.Form("PIN") <> "") then rsLoginPswd__strPIN =
Request.Form("PIN")
| %>
|
| <%
| set rsLoginPswd = Server.CreateObject("ADODB.Recordset")
| rsLoginPswd.ActiveConnection = "dsn=equilibriu-phdb;"
| rsLoginPswd.Source = "SELECT *  FROM Customers  WHERE CustomerID='" +
| Replace(rsLoginPswd__strCustomerID, "'", "''") + "' AND PIN='" +
| Replace(rsLoginPswd__strPIN, "'", "''") + "'"
| rsLoginPswd.CursorType = 0
| rsLoginPswd.CursorLocation = 2
| rsLoginPswd.LockType = 3
| rsLoginPswd.Open
| rsLoginPswd_numRows = 0
| %>
|
| <%
| If rsLoginPswd__strCustomerID <> "xyz" then
|  If Not rsLoginPswd.EOF Then
|   Session("svCustomerID") = (rsLoginPswd.Fields.Item("CustomerID").Value)
|   Session("svPIN") = (rsLoginPswd.Fields.Item("PIN").Value)
|   Session("svAccessGroup") =
(rsLoginPswd.Fields.Item("AccessGroup").Value)
|    Response.Redirect "purchase.asp"
|  Else
|   Response.Redirect "badlogin.asp"
|  End If
| End If
| %>
|
|
| Here is what I have on the page after the login:
|
| %
|
| Dim rsGetUser__MMColParam
| rsGetUser__MMColParam = Session("svCustomerID") <----This is where my ID
was
| hardcoded as a test value)
| if(Session("svCustomerID") <> "") then rsGetUser__MMColParam =
| Session("svCustomerID")
|
| %> <%
| set rsGetUser = Server.CreateObject("ADODB.Recordset")
| rsGetUser.ActiveConnection = ""
| rsGetUser.Source = "SELECT * FROM Customers WHERE CustomerID = '" +
| Replace(rsGetUser__MMColParam, "'", "''") + "'"
| rsGetUser.CursorType = 0
| rsGetUser.CursorLocation = 2
| rsGetUser.LockType = 3
| rsGetUser.Open
| rsGetUser_numRows = 0
| %>
|
|
|
| I judt don't see why is won't filter based on the session variable.  I am
| using UltraDev to help me build this site, and when I test the connection,
| the program asks me to enter a test value, if I enter my ID, the
connection
| works, but then my ID is hard coded as the session variable (I indicated
| where in the code above for the page oafter login).  So I thought if I
just
| put the session variable there instead, the recordset would filter based
| upon it, but it is not.  I am confused- it seems like it should work....
|
| Thanks for your help!
|
| Susan
|
| -----Original Message-----
| From: Cyanide _7 [mailto:leo7278(at)hotmail.com]
| Sent: Friday, December 22, 2000 2:38 PM
| To: susan(at)equilibriumdesign.com
| Cc: hwg-languages(at)hwg.org
| Subject: Re: Session variables
|
|
| are you having trouble with the Session variables or the form data? you
are
| setting the session variables after a successful login, which assumes that
| the form data was passed correctly. then it looks like you're redirecting
to
| LoginPass.asp, which i assume will be reading your session variables with
| Session("CustomerID"). where exactly is your problem? - Cyanide_7
|
|
|
| >Hello again!
| >
| >I am working on a login script in ASP.  For the login to work, the form
on
| >the page submits to itself.  But I am trying to pass a session variable
to
| >the next page, I can't get anything to pass.  Can anyone see where I am
| >going wrong?
| >
| >
| >Dim rsLogin__strCustomerID
| >rsLogin__strCustomerID = "xyz"
| >if(Request.Form("CustomerID") <> "") then rsLogin__strCustomerID =
| >Request.Form("CustomerID")
| >
| >Dim rsLogin__strPIN
| >rsLogin__strPIN = "ghtg"
| >if(Request.Form("PIN") <> "") then rsLogin__strPIN = Request.Form("PIN")
| >
| >%> <%
| >set rsLogin = Server.CreateObject("ADODB.Recordset")
| >rsLogin.ActiveConnection = ""
| >rsLogin.Source = "SELECT *  FROM Customers  WHERE CustomerID = '" +
| >Replace(rsLogin__strCustomerID, "'", "''") + "' AND PIN ='" +
| >Replace(rsLogin__strPIN, "'", "''") + "'"
| >rsLogin.CursorType = 0
| >rsLogin.CursorLocation = 2
| >rsLogin.LockType = 3
| >rsLogin.Open
| >rsLogin_numRows = 0
| >%>
| ><% If rsLogin__strCustomerID <> "xyz" then
| > If NOT rsLogin.EOF then
| > Session("svCustomerID") = (rsLogin.Fields.Item("CustomerID").Value)
| > Session("svPIN") = (rsLogin.Fields.Item("PIN").Value)
| > Session("svAccessGroup") = (rsLogin.Fields.Item("AccessGroup").Value)
| > Response.Redirect "LoginPass.asp"
| > Else
| > Response.Redirect "badlogin.asp"
| > End If
| >    End if
| >
| >
| ><form name="login" method="post" action="loginPrac.asp">
| >   Customer ID:
| >   <input type="text" name="CustomerID"><p>
| >Customer Code: <input type="text" name="PIN"><p>
| >input type="submit" value="Submit">
| >
| >
| >How do I pass the variable to the next page.  I have been testing with a
| >Request.Form("CustomerID") on the subsequent page, but nothing is
passing.
| >Any ideas?
| >
| >Thanks in advance and Merry Christmas!
| >
| >Susan
| >
|
| _________________________________________________________________
| Get your FREE download of MSN Explorer at http://explorer.msn.com
|

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA