ASP 101 - Active Server Pages 101 - Web05
The Place ASP Developers Go!

Please visit our partners

Windows Technology Windows Technology
15 Seconds
ASP 101
ASP Wire
VB Forums
VB Wire
internet.commerce internet.commerce
Partners & Affiliates

ASP 101 is an site
ASP 101 is an site
Internet News
Small Business
Personal Technology

Corporate Info
Tech Jobs
E-mail Offers

ASP 101 News Flash ASP 101 News Flash

 Top ASP 101 Stories Top ASP 101 Stories
Getting Scripts to Run on a Schedule
The Top 10 ASP Links @
What is and Why Do I Need It?

Recompiling components without rebooting
Show All Tips >>
ASP 101 RSS Feed ASP 101 Updates

Quick Tips

Basic Debugging in Classic ASP

While ASP.NET has some built in tools to aid in debugging, classic ASP is relatively lacking in that regard. This tip will show you an easy way to check the values of your application's variables and then stop execution before you do any database writes or anything else you might not want to do while testing.

This tip comes from one of our readers. Here's his email:


[I've been using this method to do some basic debugging and thought I would share it, as] I am sure someone will find it helpful.

I use the Break("Line 101: " & strTestVariableValue) to show me the output and then stop without doing anything else after it was called.

I then replace the "Break" with "Print" and move on to the next variable I would like to test.

It is very helpful when you do not want execute SQL commands lower down on your page while debugging your code because execution stops after the Break() function is called.

' DEBUG: output, continue...
Function Print(n)    
	Response.Write("<pre>" & n & "</pre>")
End Function
' DEBUG: output, stop!
Function Break(n)     
	Response.Write("<pre>" & n & "</pre>")
End Function

This type of thing is perfect for echoing out a SQL query to be sure it's correct and then stopping the script before it actually sends the query to the database and does any damage. After all, one mistake in a DELETE statement and things can get ugly!

If you prefer, you can rename the functions to something like Trace (so they're closer to the ASP.NET syntax) or whatever names you like, but regardless of what you call them, these two little functions provide a quick and easy way to do some basic debugging when things don't go as planned.

Thanks go out to Hans Mussmann for sending us this tip!

Previous      Show All Tips      Next

If you have a tip you would like to submit, please send it to:

Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback
The Network for Technology Professionals



Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers