Solved

VBScript - On Error GoTo - displays Syntax Error

Posted on 2002-03-19
7
1,830 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

828 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