ADO Connection object in Session_OnEnd

Discussion in 'ASP General' started by Agoston Bejo, Sep 24, 2004.

  1. Agoston Bejo

    Agoston Bejo Guest

    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 Bejo, Sep 24, 2004
    #1
    1. Advertising

  2. It might help if you tell us WHAT error.

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




    "Agoston Bejo" <> wrote in message
    news:...
    > 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.
    >
    >
     
    Aaron [SQL Server MVP], Sep 24, 2004
    #2
    1. Advertising

  3. >A Conn object is created the same way in Session_OnStart and is used
    >throughout the application


    O, Boy thats a bad idea

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


    "Agoston Bejo" <> wrote in message
    news:...
    > 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.
    >
    >
     
    Roji. P. Thomas, Sep 24, 2004
    #3
  4. Agoston Bejo

    Agoston Bejo Guest

    "Roji. P. Thomas" <> wrote in message
    news:e%...
    > >A Conn object is created the same way in Session_OnStart and is used
    > >throughout the application


    >
    > O, Boy thats a bad idea


    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.

    >
    > --
    > Roji. P. Thomas
    > Net Asset Management
    > https://www.netassetmanagement.com
    >
    >
    > "Agoston Bejo" <> wrote in message
    > news:...
    > > 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 Bejo, Sep 24, 2004
    #4
  5. Agoston Bejo wrote:
    > 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


    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.

    > ...
    > 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).



    http://www.aspfaq.com/2053

    > So I suppose the error is caused by the fact that we are in
    > Session_OnEnd.


    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 Barrows [MVP], Sep 24, 2004
    #5
  6. Agoston Bejo

    Agoston Bejo Guest

    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]" <> wrote in message
    news:...
    > It might help if you tell us WHAT error.
    >
    > --
    > http://www.aspfaq.com/
    > (Reverse address to reply.)
    >
    >
    >
    >
    > "Agoston Bejo" <> wrote in message
    > news:...
    > > 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 Bejo, Sep 24, 2004
    #6
  7. And what is the value of Application("Connection_String") ?

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




    "Agoston Bejo" <> wrote in message
    news:...
    > 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]" <> wrote in message
    > news:...
    > > It might help if you tell us WHAT error.
    > >
    > > --
    > > http://www.aspfaq.com/
    > > (Reverse address to reply.)
    > >
    > >
    > >
    > >
    > > "Agoston Bejo" <> wrote in message
    > > news:...
    > > > 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.
    > > >
    > > >

    > >
    > >

    >
    >
     
    Aaron [SQL Server MVP], Sep 24, 2004
    #7
  8. Agoston Bejo wrote:
    > "Roji. P. Thomas" <> wrote in message
    > news:e%...
    >>> A Conn object is created the same way in Session_OnStart and is used
    >>> throughout the application

    >
    >>
    >> O, Boy thats a bad idea

    >
    > Yeah, yeah, I think I know what you mean,


    Maybe you do, but your next statement makes me doubt it.

    > 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.
    >

    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 Barrows [MVP], Sep 24, 2004
    #8
  9. Agoston Bejo wrote:
    > 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."
    >

    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 Barrows [MVP], Sep 24, 2004
    #9
  10. Agoston Bejo

    Agoston Bejo Guest

    "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]" <> wrote in message
    news:%...
    > And what is the value of Application("Connection_String") ?
    >
    > --
    > http://www.aspfaq.com/
    > (Reverse address to reply.)
    >
    >
    >
    >
    > "Agoston Bejo" <> wrote in message
    > news:...
    > > 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]" <> wrote in message
    > > news:...
    > > > It might help if you tell us WHAT error.
    > > >
    > > > --
    > > > http://www.aspfaq.com/
    > > > (Reverse address to reply.)
    > > >
    > > >
    > > >
    > > >
    > > > "Agoston Bejo" <> wrote in message
    > > > news:...
    > > > > 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 Bejo, Sep 24, 2004
    #10
  11. Agoston Bejo

    Agoston Bejo Guest

    "Bob Barrows [MVP]" <> wrote in message
    news:Oz2Y$...
    > Agoston Bejo wrote:
    > > "Roji. P. Thomas" <> wrote in message
    > > news:e%...
    > >>> A Conn object is created the same way in Session_OnStart and is used
    > >>> throughout the application

    > >
    > >>
    > >> O, Boy thats a bad idea

    > >
    > > Yeah, yeah, I think I know what you mean,

    >
    > Maybe you do, but your next statement makes me doubt it.
    >
    > > 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.
    > >

    > 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)?


    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

    >
    > 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"
    >
    >
     
    Agoston Bejo, Sep 24, 2004
    #11
  12. Agoston Bejo wrote:
    > 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?


    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?)


    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 Barrows [MVP], Sep 24, 2004
    #12
  13. > Actually, the connection object is put into a Session variable, and is
    > reopened and closed every time an asp page is processed.


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

    > 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?


    Yes, always.
     
    Aaron [SQL Server MVP], Sep 24, 2004
    #13
  14. 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:
    > "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]" <> wrote in message
    > news:%...
    >> And what is the value of Application("Connection_String") ?
    >>
    >> --
    >> http://www.aspfaq.com/
    >> (Reverse address to reply.)
    >>
    >>
    >>
    >>
    >> "Agoston Bejo" <> wrote in message
    >> news:...
    >>> 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]" <> wrote in message
    >>> news:...
    >>>> It might help if you tell us WHAT error.
    >>>>
    >>>> --
    >>>> http://www.aspfaq.com/
    >>>> (Reverse address to reply.)
    >>>>
    >>>>
    >>>>
    >>>>
    >>>> "Agoston Bejo" <> wrote in message
    >>>> news:...
    >>>>> 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.


    --
    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 Barrows [MVP], Sep 24, 2004
    #14
  15. Agoston Bejo wrote:

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

    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 Barrows [MVP], Sep 24, 2004
    #15
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. nita
    Replies:
    1
    Views:
    904
    Saravana
    Nov 20, 2004
  2. ronaldlee

    Transfer ADO Code to ADO.NET

    ronaldlee, Dec 17, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    491
    Kevin Spencer
    Dec 17, 2004
  3. Replies:
    0
    Views:
    1,345
  4. Charles Zhang
    Replies:
    6
    Views:
    561
    Charles Zhang
    Mar 14, 2007
  5. Navin
    Replies:
    1
    Views:
    762
    Ken Schaefer
    Sep 9, 2003
Loading...

Share This Page