Solved

VBScript - On Error GoTo - displays Syntax Error

Posted on 2002-03-19
7
1,805 Views
Last Modified: 2007-12-19
I have this ASP page where I have an

<%
On Error GoTo ProcError

ASP code goes here....

ProcError:
  Session("objConn").RollbackTrans
  Session("objConn").Close
%>

Everytime I view this page in a browser, I get this error:

      VBScript error - Syntax Error on line 1

Line 1 pertains to the 'On Error GoTo ProcError'

I could not decipher why this is happening.  Thank you for your help.


0
Comment
Question by:gflorentin
  • 4
  • 2
7 Comments
 
LVL 18

Expert Comment

by:mdougan
ID: 6880375
My first guess would be that you could only use a lable, such as ProcError:  inside of a public sub or function. (that is, if you can use lables in ASP at all... you might try:

<%
Public Sub DoIt()
On Error GoTo ProcError

ASP code goes here....

ProcError:
 Session("objConn").RollbackTrans
 Session("objConn").Close
End Sub

DoIt

%>
0
 
LVL 18

Expert Comment

by:mdougan
ID: 6880377
My first guess would be that you could only use a lable, such as ProcError:  inside of a public sub or function. (that is, if you can use lables in ASP at all... you might try:

(opps, forgot the Exit Sub, this may post twice)

<%
Public Sub DoIt()
On Error GoTo ProcError

ASP code goes here....

 Exit Sub
ProcError:
 Session("objConn").RollbackTrans
 Session("objConn").Close
End Sub

DoIt

%>
0
 
LVL 18

Expert Comment

by:mdougan
ID: 6880387
My first guess would be that you could only use a lable, such as ProcError:  inside of a public sub or function. (that is, if you can use lables in ASP at all... you might try:

(opps, forgot the Exit Sub, this may post twice)

<%
Public Sub DoIt()
On Error GoTo ProcError

ASP code goes here....

 Exit Sub
ProcError:
 Session("objConn").RollbackTrans
 Session("objConn").Close
End Sub

DoIt

%>
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 18

Expert Comment

by:mdougan
ID: 6880389
My first guess would be that you could only use a lable, such as ProcError:  inside of a public sub or function. (that is, if you can use lables in ASP at all... you might try:

(opps, forgot the Exit Sub, this may post twice)

<%
Public Sub DoIt()
On Error GoTo ProcError

ASP code goes here....

 Exit Sub
ProcError:
 Session("objConn").RollbackTrans
 Session("objConn").Close
End Sub

DoIt

%>
0
 
LVL 2

Accepted Solution

by:
damienm earned 100 total points
ID: 6880396
You cannot use on error goto in ASP, only resume next.
0
 
LVL 2

Expert Comment

by:damienm
ID: 6880398
then use

if err.value <> 0 then
  response.write err.description
  response.end
end if
0
 

Author Comment

by:gflorentin
ID: 6880771
I tried that and the syntax error went away.  Thank you.

However, whenever I encounter an error, the check for the error.value does not work; for some reason, I am not capturing the error.  I found this out when I put a display of the error code - it skipped the check for error value because the error code did not get displayed.

I will have to try something else.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now