Solved

VBScript - On Error GoTo - displays Syntax Error

Posted on 2002-03-19
7
1,867 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month7 days, 22 hours left to enroll

617 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