| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I am having problem accessing the text in the Access Database field ClassYear.
The ClassYear is not returning the number from the database. I keep getting errors of object required & mismatch, though the errors not at the same time. When I attempt to fix one.... i get the other. The page is class.asp and included page is logon.asp ACTIVE SERVER PAGE - class.asp <% @language="vbscript" %> <!--#include virtual="_private/logon.inc"--> <html> <head> <meta http-equiv="Content-Language" content="en-us"> <title>Administrator</title><meta name="Microsoft Theme" content="wcps 010, default"> </head> <body> <h3 align="center">Website Security Center<br> </font>Secure Area</font></h3> <% if isAdmin then Response.Write "" else Response.Redirect "/security/errors/admin.htm" end if if ClassYear="2001" then Response.Write "" else Response.Redirect "/security/errors/classes/2001.htm" end if if isEnabled then Response.Write "" else Response.Redirect "/security/errors/disabled.htm" end if %> <p align="center"><font face="Arial"> </font> <p align="center"> </body> </html> INCLUDE FILE - logon.inc <% ' Do not cache this page. Response.CacheControl = "no-cache" ' Define the name of the users table. Const USERS_TABLE = "Security" ' Define the path to the logon page. Const LOGON_PAGE = "/security/logon.asp" ' Define the path to the logout page. Const LOGOUT_PAGE = "/security/logout.asp" ' Define the path to the logon database. Const MDB_URL = "/fpdb/SecurityCenter.mdb" Const dbUserName = "" ' username for db Const dbPassword = "" ' password for db ' Check to see whether you have a current user name. If Len(Session("uid")) = 0 Then ' Are you currently on the logon page? If LCase(LOGON_PAGE) <> LCase(Request.ServerVariables("url")) Then ' If not, set a session variable for the page that made the request... Session("REFERRER") = Request.ServerVariables("url") ' ...and redirect to the logon page. Response.Redirect LOGON_PAGE End If End If ' This function checks for a username/password combination. Function ComparePassword(uid,pwd) ' Define your variables. Dim strSQL, objCN, objRS ' Set up your SQL string. strSQL = "SELECT * FROM " & USERS_TABLE & " WHERE (UID='" & uid & "' AND PWD='" & pwd & "');" ' Create a database connection object. Set objCN = Server.CreateObject("ADODB.Connection") ' Open the database connection object. 'objCN.Open "driver={Microsoft Access Driver (*.mdb)}; dbq=" & Server.MapPath(MDB_URL) & "; uid=; pwd=" objCN.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & Server.MapPath(MDB_URL), dbUserName, dbPassword ' Run the database query. Set objRS = objCN.Execute(strSQL) if Not objRS.EOF then if len(objRS("Grant"))=4 then Session("grant")="1" ' TRUE or true = 4 it's a little trick else Session("grant")=Empty end if if len(objRS("Student"))=4 then Session("student")="1" ' TRUE or true = 4 it's a little trick else Session("student")=Empty end if if len(objRS("Teach"))=4 then Session("teach")="1" ' TRUE or true = 4 it's a little trick else Session("teach")=Empty end if if len(objRS("Board"))=4 then Session("board")="1" ' TRUE or true = 4 it's a little trick else Session("board")=Empty end if if len(objRS("Admin"))=4 then Session("admin")="1" ' TRUE or true = 4 it's a little trick else Session("admin")=Empty end if if objRS("ClassYear")="" then Session("classyear")="HELP" else Session("classyear")=objRS("ClassYear") end if if len(objRS("Enabled"))=4 then Session("enabled")="1" else Session("enabled")=Empty end if ComparePassword = True else ComparePassword = False 'Wrong UID or PWD end if ' Close your database objects. Set objRS = Nothing Set objCN = Nothing End Function Function isLogged() ' Function Return True for Logged User, something like this must called in the begin of each protected asp file. if Len(Session("uid"))=0 then isLogged=False else isLogged=True end if End Function Function logState() ' Function Return String Shows user state in system and logout text link If Len(Session("uid")) = 0 Then Response.Write "<p><b>You are not logged on.</b></p>" Else Response.Write "<p>You are logged on as: <b>" & Session("uid") & "</b> | <a href='" & LOGOUT_PAGE & "'>Logout</a></p>" End If End Function Function isGrant() 'Function Return True for Admin and Else for other users. isGrant=Cbool(Len(Session("grant"))) End function Function isStudent() 'Function Return True for Admin and Else for other users. isStudent=Cbool(Len(Session("student"))) End function Function isTeach() 'Function Return True for Admin and Else for other users. isTeach=Cbool(Len(Session("teach"))) End function Function ClassYear() Responce.Write Session("ClassYear") End function Function isBoard() 'Function Return True for Board and Else for other users. isBoard=Cbool(Len(Session("board"))) End function Function isAdmin() 'Function Return True for Admin and Else for other users. isAdmin=Cbool(Len(Session("admin"))) End function Function isEnabled() ' Function return True for Enabled users and Else for others. isEnabled=CBool(Len(Session("enabled"))) End function %> |
|
#2
|
|||
|
|||
|
Hi,
Been a while since my last ASP project, but if I recall correctly: things you put into session you need to retrieve from session. So in your case I would change If (ClassYear = "2001") then to If (Session("ClassYear") = "2001") then. Might do the trick. Grtz.© M. |
|
#3
|
||||
|
||||
|
It would also help to know the exact error message and the line of code causing the error.
|
|
#4
|
|||
|
|||
|
Quote:
There is no error message... The code prevents it... the page just sends the user to the error page. |
|
#5
|
|||
|
|||
|
Quote:
Thanks.. It worked! |
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > ASP.. Access DB.. VB... and One Stubborn Field |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|