Solved

VBScript - On Error GoTo - displays Syntax Error

Posted on 2002-03-19
7
1,824 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

773 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