Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old January 5th, 2005, 12:57 AM
wlawson wlawson is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 3 wlawson User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to wlawson
Question ASP.. Access DB.. VB... and One Stubborn Field

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>&nbsp;|&nbsp;<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
%>




Reply With Quote
  #2  
Old January 6th, 2005, 02:52 PM
Mythomep Mythomep is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: Zaandam, The Netherlands
Posts: 70 Mythomep User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 37 sec
Reputation Power: 5
Send a message via MSN to Mythomep
Cool

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.

Reply With Quote
  #3  
Old January 6th, 2005, 02:59 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,770 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 6 h 58 m 22 sec
Reputation Power: 452
It would also help to know the exact error message and the line of code causing the error.

Reply With Quote
  #4  
Old January 6th, 2005, 05:44 PM
wlawson wlawson is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 3 wlawson User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to wlawson
Quote:
Originally Posted by Memnoch
It would also help to know the exact error message and the line of code causing the error.

There is no error message... The code prevents it... the page just sends the user to the error page.

Reply With Quote
  #5  
Old January 6th, 2005, 05:46 PM
wlawson wlawson is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 3 wlawson User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to wlawson
Quote:
Originally Posted by Mythomep
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.

Thanks.. It worked!

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > ASP.. Access DB.. VB... and One Stubborn Field


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT