Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts

    global.asa - error in Session_OnEnd?

    from global.asa :
    Code:
    sub Application_OnStart
    	application("sCn") = "Provider=SQLOLEDB;Data Source=*****;Initial Catalog=*****;UID=*****;PWD=*****"
    end sub
    
    sub Application_OnEnd
    
    end sub
    
    sub Session_OnStart
    	
    end sub
    
    sub Session_OnEnd
    	'DELETE UNPURCHASED BASKET'
    	dim sSQL1 :  sSQL1 = "DELETE FROM [tblBasket] WHERE [order_id] IN(SELECT [id] FROM [tblOrders] where [tblOrders].[user_id] = "& session("userID") &" and [tblOrders].[order_status] = '1')"
    	dim sSQL2 :  sSQL2 = "DELETE FROM [tblOrders] where [user_id] = "& session("userID") &" and [order_status] = '1'"
    	dim oCn
    	set oCn = Server.CreateObject("ADODB.Connection")
    	oCn.open application("sCn")
    		oCn.execute sSQL1
    		oCn.execute sSQL2
    	oCn.close
    set oCn = nothing
    end sub
    I know that the database connection string is being dropped correctly into the application variable, so Application_OnStart is being called ok.

    I was operating under the assumption that, even if a user simply closed their browser window without "properly" ending the session, the code in Session_OnEnd would still run. It looks like I was wrong.

    Can anyone confirm/deny?

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    It does.
    There are other issues though.

    http://www.aspfaq.com/show.asp?id=2078

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #3
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    Ah. Nuts.

    thanks


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •