Does GetObject work with ASP?

R

Rich

Hello,

I have not been working with ASP for too long at this time
and am not real familiar with a lot of things about ASP.
I have searched for articles on the following question but
not come up with any definite answers. I would like to
know if it is possible to use GetObject in order to
read/write data between an ASP and an activeX
application. VBS supports GetObject, so I thought ASP
might, but I have not had any luck. Interestingly I can
use CreateObject with ASP but not GetObject. I
experimented with a homemade ActiveX exe I slapped
together with no luck - Can't create ActiveX object
error. I even tried it with an Excel workbook. Also did
not work. Before I assume you can't use GetObject with
ASP I thought I would check if maybe it is a special
syntax I need or GetObject isn't designed for ASP (Note: I
am adding my apps to the ROT to get the GetObject
functionality - which works fine from vbs). Any comments
appreciated.

Thanks,
Rich
 
S

Steven Burn

Look into FSO (FileSystemObject)

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
 
R

Rich

Thanks for that suggestion. I think I have played around
a little bit with FileSystemObject but was using the wrong
syntax and lost hope. Finally got it to work:

set fso = CreateObject("Scripting.FileSystemObject")
Set info = fso.CreateTextFile("ActiveXasptestR.txt")
info.WriteLine "testing"
info.Close

Just needed a little encouragement.

Thanks again,
Rich
 
S

Steven Burn

hehe, no problem ;o)

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
 
R

Rich

Thank you for pointing this out. Actually, I do set fso
to nothing. While I'm at it, may I ask how or if you
could use FileSystemObject to write/pass data to an
ActiveX app? (VB6 activeX app). Like in MS Access I could
make a reference to myApp (which would be running and
visible) and do this:

Dim x As New myApp.Class1
x.letSomething = "test"
set x = nothing

where .letSomething is some Public Property Let... in
Class1 and "test" would end up in a textbox on a form of
myApp. Is it possible to use FileSystemObject to do
something similar in ASP (or vbs for that matter? For vbs
I added GetObject functionality to my activeX app by
adding it to the Windows Running Object Table and hooking
it, but GetObject not working with ASP this way - which is
what this post is about). If I can do something like this
with FileSystemObject, may I ask how this is done? sample
syntax.

Thanks,
Rich
 
J

Jon Mundsack

Aaron Bertrand said:
set info = nothing
set fso = nothing

Doesn't ASP release its variables after it's done with the response? I
mean, as long as you release resources (e.g., close open files, recordsets,
connections, etc.), is there something about taking advantage of ASP's
implicit cleanup that is somehow distasteful? Not trying to be
argumentative, just really want to know. Thanks.
 
B

Bob Barrows

Jon said:
Doesn't ASP release its variables after it's done with the response?
I mean, as long as you release resources (e.g., close open files,
recordsets, connections, etc.), is there something about taking
advantage of ASP's implicit cleanup that is somehow distasteful? Not
trying to be argumentative, just really want to know. Thanks.

There are situations when automatic cleanup cannot occur, especially with
recordsets (and therefore connections as well). It pays to be explicit.

Bob Barrows
 
J

Jon Mundsack

Bob Barrows said:
There are situations when automatic cleanup cannot occur, especially with
recordsets (and therefore connections as well). It pays to be explicit.

Again, not being argumentative, but can you give me an example of a
situation where letting a variable fall out of scope would have a different
effect than setting it to Nothing? Granted, you've got to close recordsets
and connections, etc., but it seems like you're saying ASP can hold a
reference to an object that from all outward appearances has fallen out of
scope. Is that correct? (The reason I'm so concerned is that I rely on ASP
to release variables all the time, so naturally if it turns out this is bad
I'll have to change my ways.)
 
B

Bob Barrows

Jon said:
Again, not being argumentative, but can you give me an example of a
situation where letting a variable fall out of scope would have a
different effect than setting it to Nothing? Granted, you've got to
close recordsets and connections, etc., but it seems like you're
saying ASP can hold a reference to an object that from all outward
appearances has fallen out of scope. Is that correct? (The reason
I'm so concerned is that I rely on ASP to release variables all the
time, so naturally if it turns out this is bad I'll have to change my
ways.)

It's been a while since I read about this so I don't remember the details
but a recordset object can be in a state where it cannot be closed by going
out of scope (for example, there may be an ongoing or pending Update
operations). This leaves it in memory causing a memory leak which can
eventually crash IIS if it happens enough times.

It has been very well documented in these groups where people have had
problems with IIS crashing every few days, which they have resolved by
modify their code and explicitly closing and destroying their ADO objects.

My simple rule is: If I open it, I close it. If I create it, I destroy it.

Bob Barrows
 
A

Aaron Bertrand - MVP

Again, not being argumentative, but can you give me an example of a
situation where letting a variable fall out of scope would have a different
effect than setting it to Nothing?

Why should I set my objects to nothing?

Well, for one, when you explicitly set it to nothing, it is released
immediately (IIS 5.0 and later). If you don't bother, it will wait until
the page goes out of scope. I'll leave it as an exercise to the reader to
determine which option is more efficient.

I believe one example of much more detrimental behavior: A recordset object
that holds a pessimistic lock can tie up resources long after the page goes
out of scope, if the transaction is neither committed nor rolled back. Not
sure how trivial it is to reproduce and demonstrate this phenomenen.

Why people *want* to be lazy and leave out destruction statements is beyond
me. I've never trusted automatic garbage collection, and probably never
will -- I follow Bob's simple rule to the letter. Just write the extra 20
characters and be done with it.
 

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
474,261
Messages
2,571,040
Members
48,769
Latest member
Clifft

Latest Threads

Top