Debugging ASP

1. In Internet Explorer, you may get a "page can't be displayed" message without a specific ASP error message.  To see the error message, select Tools>Internet Options>Advanced> and under Browsing, uncheck the box "Show friendly HTTP error messages".  Alternatively, view the page in Netscape to see the ASP error.

2. In operations with a database, one often has to pass a string to an ASP method and this string is formed by concatenating a string constant with the value returned by a variable or an ASP method.  If you get an error message, assign the result to a variable and then pass the variable to the ASP method.  For example, instead of writing

dbConnection.Execute("INSERT INTO students (first, last, state) VALUES (' "  + Request.Form("first") + sep + Request.Form("last") + sep + Request.Form("state") + "')";

Use the following code:

str = "INSERT INTO students (first, last, state) VALUES (' "
str += Request.Form("first") + sep + Request.Form("last") + sep + Request.Form("state") + "')";
dbConnection.Execute(str);

This has two advantages:

3. To display the value of a variable bill on the screen in ASP, you can write either of the following:

4. If you get an error message you can't understand, even after displaying the values of variables that may be involved in the error, search the Microsoft Knowledge Base for the error message.  Go to www.microsoft.com, click on Support, Knowledge Base (in left hand navigational bar), and then enter the error message and the product (Active Server Pages).  Also pay attention to the number of the error message.  The articles will often explain the reason for the error message.  Here are two examples of error messages we've had recently and the explanation in the article:   

a) "Microsoft OLE DB Provider for ODBC Drivers error '80040e10'
[Microsoft][ODBC Microsoft Access 97 Driver]
Too few parameters. Expected 1. 

This error occurs because the column name that you used in the query syntax does not exist. Often this error is just a typographical error. Check the column names in a database against your query string ..."

b)  Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access 97 Driver]
Syntax error in INSERT INTO statement.

Cause

This error occurs because a column name may be a reserved word, such as "DATE." Change the column name to a non-reserved name, such as "SaleDate."

Revised: October 6, 2002. Comments to William Pegram, wpegram@nvcc.edu