Pages

Tuesday, July 3, 2012

Types of Error Asp

Identifying the types of Errors in asp

Types of Errors in Asp
  1. Compilation error in asp
  2. Run time error in asp
  3. Logical error in asp
Suppose a visitor to a web page sees the following error message:-
"Microsoft OLE DB Provider for ODBC Drivers error "80004005" [Microsoft][ODBC MICROSOFT ACCESS 97 Driver] The Microsoft jet database engine cannot open the file '(unknown)'. It is already opened opened exclusively by another user, or you need permission to view its data."
Such error prevent visitors from viewing Web pages properly and annoy them. Errors can spoil a well written code in asp. There fore  error handling in asp is extremely important point



Compilation Errors in asp is Syntax errors that stop scripts from compiling on Web Server  
The below code when executed will produces a compilation error in asp. The reason why this error is displayed is that in the code the <%option explicit%> statement is used. If it is used in code, a variable must be explicitly declared in code before it can be used. other wise it will give error as shown in image 

<% Option Explicit %>
<%
Age = 12
response.write Age
%>

compilation error in asp
Run time errors
Run time error occurs from unforeseen condition. For example a script may contain a reference to file at specific location in computer. However if the file is deleted or moved  from that location, an error is caused during run time.

In the below code include file is not present.

<!-- # include virtual  ="adovbs.inc" -- >
<html>
<title>Run time errors</title>
</html>



Logical Errors
Errors due to improper logic is known as logical errors. Logical errors are type of run time error. logical error are caused due to error in logic or algorithm. Logical error refers to undefined behavior and results.
For example An array contains value starting from Zero to TotalCount.  Assume that to retrieve the values stored in the array, you write the following code.

For i = 0 to TotalCount

This statement leads to an error, as the array index starts from 0. The correct way to write the code is 

For i = 0 to TotalCount - 1

No comments:

Post a Comment