I just learned how to use the Session Objects. I used the "Site Security
Sample: Design Documentation." It uses the Session_OnStart event. I got it
to work fine. Then I started a new application in which I copied all my
pages and includes, and the database, from my existing application(not the
Site Securit Sample). I made changes to various pages so it would conform
to the sample application above. My problem follows;
My first page is a Logon page(UserID and Password), called Logon2.asp. It
has a Form action = Default.asp. After entering the user id and password,
I get the following error;
"An exception of type "Runtime Error was not handled. Would you like to
debug the application?". When I respond with "Yes", Interdev points to the
following line in Global.asa. Session.Timeout = 10
Please see the code for Logon2.asp and Global.asa below. I believe it has
something to do with opening the recordset, but can't prove it.
Thank you very much for any help with this.
Larry
___________________________________________________________________________
Logon2.asp
<%@LANGUAGE="VBScript" ENABLESESSIONSTATE=false%>
<%'ENABLESESSIONSTATE=True Needed so Form elements
'will be passed the first time (bug???)%>
<%Option Explicit%>
<%Response.Expires = -1%>
<%Response.Buffer = True%>
<!--#Include File="config.inc"-->
<html>
<head>
<title>Administrative Server Logon</title>
</head>
<!--#Include File="comtop.inc"-->
<table ALIGN="CENTER" CELLPADDING="8" CELLSPACING="0" BORDER="0">
<tr><td CLASS="clsTop" COLSPAN="2">
<b>Welcome to the Reservation system </b>
</td></tr>
<tr><td CLASS="clsTD2" COLSPAN="2">
<img SRC="images/key.gif" BORDER="0" WIDTH="22" HEIGHT="10">
Please Logon to the Schedule
<br>
___________________________________________________________________________
Global.asa
<form ACTION="default.asp" METHOD="post" NAME="frmLogon">
<tr>
<td CLASS="clsTD" ALIGN="CENTER">
<p>User ID:</p>
<p>Password: </p>
<p> </p>
</td>
<td CLASS="clsTD2">
<input NAME="txtuserid" CLASS="Text" SIZE="20">
<p>
<input TYPE="password" NAME="txtpassword" CLASS="clsInput2"
SIZE="20">
</p>
</td>
</tr>
<tr><td CLASS="clsBottom" COLSPAN="2" ALIGN="CENTER"><br>
<input TYPE="SUBMIT" VALUE="Submit" CLASS="clsInput"
NAME="btnSubmit" ONMOUSEOVER="buttonchange('1')" ONMOUSEOUT="buttonchange
('0')">
</td></tr>
</form>
</table>
<!--#Include File="combot.inc"-->
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
'You can add special event handlers in this file that will get run
automatically when
'special Active Server Pages events occur. To create these handlers, just
create a
'subroutine with a name from the list below that corresponds to the event
you want to
'use. For example, to create an event handler for Session_OnStart, you
would put the
'following code into this file (without the comments):
'Sub Session_OnStart
'**Put your code here **
'End Sub
'EventName Description
'Session_OnStart Runs the first time a user runs any page in your
application
'Session_OnEnd Runs when a user's session times out or quits your
application
'Application_OnStart Runs once when the first page of your application
is run for the first time by any user
'Application_OnEnd Runs once when the web server shuts down
</SCRIPT>
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
' try to validate the user, see comments in pgAccountAccess.htm
Sub Session_OnStart
Dim cn ' ado connection object
Dim rs ' ado recordset object
Dim strSQL ' sql query string
Dim struserid ' name of user(from logon2.asp)
Dim strPassword ' password (from logon2.asp)
' set session timeout to 10 minutes
Session.Timeout = 10
' get the login info the user entered in logon2.asp
struserid = Request.Form("txtuserid")
strPassword = Request.Form("txtPassword")
' make sure they did not leave the fields blank
If struserid = "" And strPassword = "" Then
' no login information at all, abandon the
' session and send to the login page
Session.Abandon
Response.Write "session abandoned"
Response.Redirect "logon2.asp"
Else
' see if user entered valid login information
' first, create the connection and recordset
Set cn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
' build the query string using info collected from the
' login page (pgAccountAccess.htm)
strSQL = "SELECT userid, logon FROM tbllogons WHERE " & _
"(UserID = '" & struserid & "') AND " & _
"(Logon = '" & strPassword & "')"
' Open the connection, the connection string, username and
password
' are stored in the Application object which was created
by the
' Data Environment connection wizard
cn.Open Application("maxxschedule_ConnectionString"), _
Application("maxxschedule_RuntimeUserName"), _
Application("maxxschedule_RuntimePassword")
' open the recordset
rs.Open strSQL, cn
' see if found a recordset, if we did, the user entered
' valid information in the login page
If Not rs.EOF Then
' login successful
' save variables that can be accessed by other
pages
Session("Logon") = rs("Logon")
Session("UserID") = rs("UserID")
' clean up the ado objects
Set cn = Nothing
Set rs = Nothing
' display the success page
Response.Redirect "default.asp"
Else
' login failed
' clean up the ado objects
Set cn = Nothing
Set rs = Nothing
' abandon the session and display the
' login failed page
Session.Abandon
Response.Redirect "logon2.asp"
End If
End If
End Sub
</SCRIPT>
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Application_OnStart
'==Visual InterDev Generated - startspan==
'--Project Data Connection
Application("maxxschedule_ConnectionString")
= "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data
Source=F:\calendar\calendar_Local\data\MaxxSchedule.mdb;Mode=Share Deny
None;Extended Properties="""";Jet OLEDB:System database="""";Jet
OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine
Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk
Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database
Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt
Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet
OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;User
Id=Admin;Password=;"
Application("maxxschedule_ConnectionTimeout") = 15
Application("maxxschedule_CommandTimeout") = 30
Application("maxxschedule_CursorLocation") = 3
Application("maxxschedule_RuntimeUserName") = "Admin"
Application("maxxschedule_RuntimePassword") = ""
'-- Project Data Environment
'Set DE = Server.CreateObject("DERuntime.DERuntime")
'Application("DE") = DE.Load(Server.MapPath
("Global.ASA"), "_private/DataEnvironment/DataEnvironment.asa")
'==Visual InterDev Generated - endspan==
End Sub
</SCRIPT>