Procedures don't have access to public Variables in ASP

B

Bobby Howell

Hi.

I have the following which I use either on my server using cscript (.vbs
file) or identical code in my ASP pages. The problem is when running in ASP
I recieve the following error:
Microsoft VBScript runtime error '800a01f4'
Variable is undefined: 'iMsg'
/scripts/processdata.asp, line 257

The error is raised when my DeallocateResouces procedure attempts to
deallocate resources for objects (set iMsg = Nothing). However, when I run
my .vbs file which is on the server using wscript or cscript all is fine.
Just like in VB. The only difference is the QuitOnError() procedure. In
the ASP file I use scripting to popup alert to user. However in .vbs file
on server I write events to app log.

Why don't my procedures have access to the variables in asp, but do in
standard vbs files? How do I fix? As you know, by default procedures are
public. Thank you in advance

<<<<<Code of .asp file used on web and also in .vbs file on server>>>>
..
..
..
call SendEmail
call DeallocateResources

sub SendEmail
' on error resume next
dim iMsg, iConf, Flds

const cdoSendUsingPort = 2

set iMsg = CreateObject("CDO.Message")
call QuitOnError
set iConf = CreateObject("CDO.Configuration")
call QuitOnError
set Flds = iConf.Fields
call QuitOnError
..
..
..
end sub

sub DeallocateResources()
' on error resume next

set iMsg = Nothing
set iConf = Nothing
set Flds = Nothing
end sub

sub QuitOnError()
' on error resume next

if err.number <> 0 then
%>
<script language="vbscript">
alert("Your message could not be sent at this time. Please click the
Back button and try again.")
</script>
<%
call DeallocateResources
Response.Clear
Response.End
end if
end sub
 
E

Evertjan.

Bobby Howell wrote on 17 sep 2005 in
microsoft.public.inetserver.asp.general:
Why don't my procedures have access to the variables in asp, but do in
standard vbs files? How do I fix? As you know, by default procedures
are public. Thank you in advance

ASP has a seperate user, having not much security-clearance.

It is a good thing ASP-scriptcodes cannot reach the internals of your
server.

Use a session [or application] variable for in-ASP cross-page variable.
 
B

Bob Barrows [MVP]

Bobby said:
Hi.

I have the following which I use either on my server using cscript
(.vbs file) or identical code in my ASP pages. The problem is when
running in ASP I recieve the following error:
Microsoft VBScript runtime error '800a01f4'
Variable is undefined: 'iMsg'
/scripts/processdata.asp, line 257

The error is raised when my DeallocateResouces procedure attempts to
deallocate resources for objects (set iMsg = Nothing). However,
when I run my .vbs file which is on the server using wscript or
cscript all is fine. Just like in VB. The only difference is the
QuitOnError() procedure. In the ASP file I use scripting to popup
alert to user. However in .vbs file on server I write events to app
log.
Why don't my procedures have access to the variables in asp, but do in
standard vbs files? How do I fix? As you know, by default
procedures are public. Thank you in advance

<<<<<Code of .asp file used on web and also in .vbs file on server>>>>
.
.
.
call SendEmail
call DeallocateResources

sub SendEmail
' on error resume next
dim iMsg, iConf, Flds

Since these are declared inside the sub, they are NOT pupblic variables.
They need to be declared outside the sub in order to be public ...
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"
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top