Setting Access Table Value for Session (Full Version)

All Forums >> [Web Development] >> ASP, PHP, and Database



Message


Mav44 -> Setting Access Table Value for Session (10/16/2009 18:58:04)

Hi, I am using the following login script to pull from an access database. I would also like to be able to pull other variables such as "repgrp" from this database to be used during that session on other pages. My login looks like:


<%@ LANGUAGE="VBSCRIPT" %>
<%
Dim myConn 
'Query to be executed
Dim SQLQuery 
'Recordset
Dim rs 
'StudentNo Of Logged in user
Dim UserName 
'Password of User
Dim Password
set Conn=server.createobject("ADODB.Connection") 
'Creating Recordset Object 
set rs = Server.CreateObject("ADODB.Recordset") 
connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" 
connStr = connStr + server.MapPath("mymembers.mdb")
Conn.open connStr 

Dim Conn, oRSu
username = request.form("username")
password = Request.Form("Password")
repgrp = Request.Form("repgrp")
if Session("ausr") = "" or Request.Form("usrname") <> "" then
Session("ausr") = ""
Set oRSu = Conn.Execute("SELECT * from users where username = '" & username & "' and password = '" & password & "' ") 

if oRSu.EOF then 
Response.Redirect "zlogin.asp?username=" & UserName 
End if 

if not oRSu.EOF then

Session("ausr") = trim(oRSu ("username"))
Session("repgrp") = Request.Form("repgrp")


If Len(Request("requester")) > 0 Then
Response.Redirect (Request("requester"))
Else
Response.Redirect "zlogin.asp?UserName=blank"
End if
end if

end if
%>


I would then like to put something like this on any page in my site that would bring the value for "repgrp" to that page. Something like:


repgrp = session("repgrp")

sql = "select * from mydata where status = 'Pending' and repfirm like '%" & repgrp & "%' "


I have been unable to get the "repgrp" session results results sent to the other pages. Any help is greatly appreciated!




Spooky -> RE: Setting Access Table Value for Session (10/17/2009 1:36:01)

Does repgrp come from the database?
If so, why not do this?

Session("repgrp") = oRSu("repgrp")




Mav44 -> RE: Setting Access Table Value for Session (10/17/2009 1:42:10)

That is it. I changed Session("repgrp") = Request.Form("repgrp") to Session("repgrp") = trim(oRSu ("repgrp")) and everything is working great!




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.0390625