Professional Web Applications Themes

ADO Connection object in Session_OnEnd - ASP Database

Hi! Why doesn't the following code work? Sub Session_OnEnd Dim Conn Set Conn = Server.CreateObject("ADODB.Connection") Conn.ConnectionString = Application("Connection_String") Conn.Open 'here is the error .... End Sub A Conn object is created the same way in Session_OnStart and is used throughout the application, and Application("Connection_String") still exists here (I tested). So I suppose the error is caused by the fact that we are in Session_OnEnd....

  1. #1

    Default ADO Connection object in Session_OnEnd

    Hi!
    Why doesn't the following code work?

    Sub Session_OnEnd
    Dim Conn
    Set Conn = Server.CreateObject("ADODB.Connection")
    Conn.ConnectionString = Application("Connection_String")
    Conn.Open 'here is the error
    ....
    End Sub


    A Conn object is created the same way in Session_OnStart and is used
    throughout the application, and Application("Connection_String") still
    exists here (I tested).
    So I suppose the error is caused by the fact that we are in Session_OnEnd.


    Agoston Guest

  2. #2

    Default Re: ADO Connection object in Session_OnEnd

    It might help if you tell us WHAT error.

    --
    http://www.aspfaq.com/
    (Reverse address to reply.)




    "Agoston Bejo" <hu> wrote in message
    news:phx.gbl... 


    Aaron Guest

  3. #3

    Default Re: ADO Connection object in Session_OnEnd

    >A Conn object is created the same way in Session_OnStart and is used 

    O, Boy thats a bad idea

    --
    Roji. P. Thomas
    Net Asset Management
    https://www.netassetmanagement.com


    "Agoston Bejo" <hu> wrote in message
    news:phx.gbl... 


    Roji. Guest

  4. #4

    Default Re: ADO Connection object in Session_OnEnd


    "Roji. P. Thomas" <com> wrote in message
    news:e%phx.gbl... [/ref]
     

    Yeah, yeah, I think I know what you mean, but as far as I know, it's not
    that bad idea if you close the connection at the end of every asp page and
    reopen it at the beginning of them.
     [/ref]
    Session_OnEnd. 
    >
    >[/ref]


    Agoston Guest

  5. #5

    Default Re: ADO Connection object in Session_OnEnd

    Agoston Bejo wrote: 

    What is the error? I suggest instead of posting it here, you go to
    aspfaq.com and search for it there. You may get your answer quicker.
     


    http://www.aspfaq.com/2053
     

    Who can say without knowing what the error is?

    Bob Barrows

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Guest

  6. #6

    Default Re: ADO Connection object in Session_OnEnd

    Yes, how silly of me, I forgot that little detail:

    Error message:
    "Requested operation requires an OLE DB Session object, which is not
    supported by the current provider."


    "Aaron [SQL Server MVP]" <noraa> wrote in message
    news:phx.gbl... [/ref]
    Session_OnEnd. 
    >
    >[/ref]


    Agoston Guest

  7. #7

    Default Re: ADO Connection object in Session_OnEnd

    And what is the value of Application("Connection_String") ?

    --
    http://www.aspfaq.com/
    (Reverse address to reply.)




    "Agoston Bejo" <hu> wrote in message
    news:phx.gbl... [/ref]
    > Session_OnEnd. 
    > >
    > >[/ref]
    >
    >[/ref]


    Aaron Guest

  8. #8

    Default Re: ADO Connection object in Session_OnEnd

    Agoston Bejo wrote: [/ref]

    >
    > Yeah, yeah, I think I know what you mean,[/ref]

    Maybe you do, but your next statement makes me doubt it.
     
    Then what's the point of opening it in Session_OnStart? Maybe you misspoke
    in your earlier message. When you said " ... and is used throughout the
    application", were you talking about the connection object (bad) or the
    connection string (good)?

    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Guest

  9. #9

    Default Re: ADO Connection object in Session_OnEnd

    Agoston Bejo wrote: 
    Hmm. What provider are you using?

    Bob Barrows

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Guest

  10. #10

    Default Re: ADO Connection object in Session_OnEnd

    "Provider=OraOLEDB.Oracle.1;Data Source=***;User ID=***;Password=***;Persist
    Security Info=True;PLSQLRSet=1;"

    Sorry, but I don't think I should provide the information that I've replaced
    with ***.
    I'm connecting to an Oracle 8.1.7 server.
    Anyway, believe me that it works this way outside Session_OnEnd, since I
    copied
    it from Session_OnStart.

    Many thanks

    "Aaron [SQL Server MVP]" <noraa> wrote in message
    news:%phx.gbl... [/ref][/ref]
    still 
    > > Session_OnEnd. 
    > >
    > >[/ref]
    >
    >[/ref]


    Agoston Guest

  11. #11

    Default Re: ADO Connection object in Session_OnEnd


    "Bob Barrows [MVP]" <SPAMcom> wrote in message
    news:Oz2Y$phx.gbl... 
    > > 
    > >
    > > Yeah, yeah, I think I know what you mean,[/ref]
    >
    > Maybe you do, but your next statement makes me doubt it.

    > Then what's the point of opening it in Session_OnStart? Maybe you misspoke
    > in your earlier message. When you said " ... and is used throughout the
    > application", were you talking about the connection object (bad) or the
    > connection string (good)?[/ref]

    It isn't opened in Session_OnStart.
    In Session_OnEnd I open it only because I create a new Connection object.
    (That part --"Conn.Open"-- doesn't come from Session_OnStart, all right.)
    Actually, the connection object is put into a Session variable, and is
    reopened and closed every time an asp page is processed.
    From what you (and the others) say, it shouldn't be done this way, and I
    should create a new Connection object in every asp page. Right?

    Anyway, the original problem has not much to do with this, so let's now
    concentrate on that part. (Why doesn't the newly created Connection
    object --initialized with a valid connection string-- work in
    Session_OnEnd?)

    Thx
     


    Agoston Guest

  12. #12

    Default Re: ADO Connection object in Session_OnEnd

    Agoston Bejo wrote: 

    Right
     

    I've never seen this message, but that may be because I've only used the SQL
    Server and Jet providers. I have no experience with the Oracle provider. The
    only clue I can offer is that the IWAM account (not the IUSR) is the user
    during Session_OnEnd. There may be some permissions lacking somewhere
    (perhaps in the Registry) for this user. Sorry I can't be of more help. Have
    you tried Google or an Oracle forum/newsgroup?

    Bob Barrows

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Guest

  13. #13

    Default Re: ADO Connection object in Session_OnEnd

    > Actually, the connection object is put into a Session variable, and is 

    No, no, no, don't do this, ever.
     

    Yes, always.


    Aaron Guest

  14. #14

    Default Re: ADO Connection object in Session_OnEnd

    You can try disableing session pooling for this connection by adding

    OLE DB Services=-2

    to your connection string in this sub.

    Bob Barrows

    Agoston Bejo wrote: [/ref][/ref]

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Guest

  15. #15

    Default Re: ADO Connection object in Session_OnEnd

    Agoston Bejo wrote:

    This seems to have your answer:
    http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&selm=CUjrpd2vBHA.392%40cpmsftngxa09

    The solution is to stop using a connection is Session, or impair performance
    by turning OLEDB session pooling off

    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Guest

Similar Threads

  1. Session_OnEnd not working
    By Joel Brabant in forum ASP
    Replies: 1
    Last Post: September 20th, 05:11 PM
  2. Replies: 3
    Last Post: September 7th, 12:27 PM
  3. Global.asa - Session_OnEnd Question ..
    By MostlyH2O in forum ASP
    Replies: 6
    Last Post: July 28th, 04:05 PM
  4. my session_onend is not working
    By anand in forum ASP.NET General
    Replies: 4
    Last Post: July 22nd, 04:47 AM
  5. Session_OnEnd - timeout or close?
    By Tom B in forum ASP
    Replies: 2
    Last Post: July 18th, 07:37 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139