469,898 Members | 1,599 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,898 developers. It's quick & easy.

Procedures don't have access to public Variables in ASP

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


Sep 17 '05 #1
2 1520
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.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Sep 17 '05 #2
Bobby Howell wrote:
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"
Sep 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Kent Lewandowski | last post: by
5 posts views Thread by Tim Marshall | last post: by
2 posts views Thread by Quinnie | last post: by
3 posts views Thread by R Millman | last post: by
8 posts views Thread by gemel | last post: by
5 posts views Thread by patrick.cc.choi | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.