ADO Connection object in Session_OnEnd

A

Agoston Bejo

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

Agoston Bejo

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

Bob Barrows [MVP]

Agoston said:
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
 
A

Agoston Bejo

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

Bob Barrows [MVP]

Agoston said:
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
 
B

Bob Barrows [MVP]

Agoston said:
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
 
A

Agoston Bejo

"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
 
A

Agoston Bejo

Bob Barrows said:
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)?

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
 
B

Bob Barrows [MVP]

Agoston said:
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
 
A

Aaron [SQL Server MVP]

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

Bob Barrows [MVP]

You can try disableing session pooling for this connection by adding

OLE DB Services=-2

to your connection string in this sub.

Bob Barrows
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top