INTERNET INTRANET NETWORKS PROGRAMMING

View ASP Code (/bret/resume/adotutorial/copyofglobal.asa)
Go Back to


<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

Sub Session_OnStart

   Dim sMsg
   Dim objMailer
   Dim objBrowser
   Dim conDB
   Dim cmdMain
   Dim rsData

   'Create and persist the Connection object
   Set conDB = Server.CreateObject("ADODB.Connection")
   'conDB.Open "FLASH"
   conDB.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=D:\216.247.161.1\flash\flash.mdb;"
   Set Session("CON") = conDB

   'Create and persist the Command object
   Set cmdMain = Server.CreateObject("ADODB.Command")
   cmdMain.CommandText="Select * From FlashCards WHERE CardID <= 30"
   Set cmdMain.ActiveConnection = conDB
   Set Session("CMD") = cmdMain

   'Create and persist the Recordset object
   Set rsData = Server.CreateObject("ADODB.Recordset")
   rsData.Open cmdMain,,3,3
   Set Session("DATA") = rsData

End Sub

Sub Session_OnEnd
     
      On Error Resume Next

   rsData.Close
   conDB.Close
  
   Set rsData = Nothing
   Set cmdMain = Nothing
   Set conDB = Nothing
  
End Sub

</SCRIPT>