Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Debugging for Beginners

Status
Not open for further replies.

Dynapen

Programmer
Apr 20, 2000
245
US
Alot of people in the forum ask simple questions about how to debug parts of their asp pages. And alot of those same questions can be answered with the same statement

Response.Write
Response.End

These two statements can be combined to be the best ASP debugger out there, and they are extremely easy to use.

If you have a page that you don't think is running, but a
Response.Write "Text"
Response.End
at the beginning. If the text you entered appears, then you know you are getting at least that far. (Remember before you get to sure that it doesn't run, sometimes it is helpful to bounce the browser to clear the session objects and the cache)

Have some if statements that are running right? Try this.

If Condition1 = True then
Response.write "Condition1"
Response.End
If Condition2= True then
Response.write "Condition2"
Response.end

Then run the code, and remove the response.writes as you see them. The first time you don't see a new Condition written to the page, then you know you aren't gettign into that IF, and you have found the variable causing the problem.

Best place to use Response.write is with DB connections. This can allow you to see the actual code that is being submitted to the database. This means you can copy and paste it to the DB and test it that way. You can see if maybe you missed a literal when you created the SQL statement.

Response.write
Response.end

are simply the easiest way to learn basic ASP debugging. The more you use them, the more you will learn about how ASP works, and how to debug it.
The money's gone, the brain is shot.....but the liquor we still got.
 
Two points:
1. Shouldn't this be a FAQ?
2. I use the response.write/end all the time, but user beware!: If you have a db-connection open, either response.end before you open it or close it before you end processing. If you don't you will eventually bring the server to it's knees, due to all the open connections. This is especially an issue when dealing with ms-access. This is not a bug - it's an undocumented feature...
;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top