Page 3 - Discuss Debugging techniques in the ASP Development forum on ASP Free. Debugging techniques ASP Development forum discussing ASP related topics including coding practices, ASP tips, and more. Active Server Pages (ASP) enables you to empower your HTML pages dynamically with robust scripting options.
We cover the world of technology
like no one else, constantly updating you with the best information
available on open source software, Microsoft technologies, hardware
and news from around the world.
Posts: 5,410
Time spent in forums: 3 Weeks 4 Days 12 h 36 m
Reputation Power: 1332
Quote:
Originally Posted by jmurrayhead
Something that hasn't been mentioned in this thread and that I see a lot of with new developers is unformatted code. Take these two samples for instance:
Code:
<%@ Language=VBScript %>
<%
set conn = Server.CreateObject("ADODB.Connection")
conn.Open "DSN=AdvWorks"
set rs = Server.CreateObject("ADODB.Recordset")
rs.CursorLocation = 3 ' adUseClient
rs.Open "Select * from Employees", conn
rs.PageSize = 2
intPageCount = rs.PageCount
Select Case Request("Action")
case "<<"
intpage = 1
case "<"
intpage = Request("intpage")-1
if intpage < 1 then intpage = 1
case ">"
intpage = Request("intpage")+1
if intpage > intPageCount then intpage = IntPageCount
Case ">>"
intpage = intPageCount
case else
intpage = 1
end select
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>ASP & ADO Paging</TITLE>
</HEAD>
<BODY bgColor=White text=Black>
<%
rs.AbsolutePage = intPage
For intRecord = 1 To rs.PageSize
Response.Write "Record number: " & intRecord & " "
Response.Write rs.Fields("FirstName") & " "
Response.Write rs.Fields("LastName") & "<br>"
rs.MoveNext
If rs.EOF Then Exit For
Next
rs.Close
set rs = Nothing
conn.Close
set conn = nothing
%>
<form name="MovePage" action="default.asp" method="post">
<input type="hidden" name="intpage" value="<%=intpage%>">
<input type="submit" name="action" value="<<">
<input type="submit" name="action" value="<">
<input type="submit" name="action" value=">">
<input type="submit" name="action" value=">>">
Page: <%=Intpage & " of " & intpagecount%>
</form>
</BODY>
</HTML>
Code:
<%@ EnableSessionState=False Language=VBScript %>
<%
set conn = Server.CreateObject("ADODB.Connection")
conn.Open "DSN=AdvWorks"
set rs = Server.CreateObject("ADODB.Recordset")
rs.CursorLocation = 3 ' adUseClient
rs.Open "Select * from Employees", conn
rs.PageSize = 2
intPageCount = rs.PageCount
Select Case Request("Action")
case "<<"
intpage = 1
case "<"
intpage = Request("intpage")-1
if intpage < 1 then intpage = 1
case ">"
intpage = Request("intpage")+1
if intpage > intPageCount then intpage = IntPageCount
Case ">>"
intpage = intPageCount
case else
intpage = 1
end select
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>ASP & ADO Paging</TITLE>
</HEAD>
<BODY bgColor=White text=Black>
<%
rs.AbsolutePage = intPage
For intRecord = 1 To rs.PageSize
Response.Write "Record number: " & intRecord & " "
Response.Write rs.Fields("FirstName") & " "
Response.Write rs.Fields("LastName") & "<br>"
rs.MoveNext
If rs.EOF Then Exit For
Next
rs.Close
set rs = Nothing
conn.Close
set conn = nothing
%>
<form name="MovePage" action="default.asp" method="post">
<input type="hidden" name="intpage" value="<%=intpage%>">
<input type="submit" name="action" value="<<">
<input type="submit" name="action" value="<">
<input type="submit" name="action" value=">">
<input type="submit" name="action" value=">>">
Page: <%=Intpage & " of " & intpagecount%>
</form>
</BODY>
</HTML>
Which one is easier to read? I hope you say the one on the bottom. When debugging code, having some type of formatted code (using indents, spaces, etc.) makes debugging much easier because the page is easier to read. Think about the first code sample above if it were a much larger application. Even if you have an editor that shows each line and an error shows the exact line..having formatted text still makes it much easier to debug.
Excellent point!!!
__________________
I would rather know than not know at all...
Posts: 1
Time spent in forums: 30 m 13 sec
Reputation Power: 0
Debugging techniques
I think this Logger Control could be quite useful. ASP.NET AJAX has a similar concept, however the feature set isn't quite as rich (compare the YUI demo with the ASP.NET AJAX demo and I think you will see what I mean). To assist in debugging ASP.NET AJAX applications, Microsoft created the Sys.Debug helper class
--------------------------
Ann
How to Present Effectively Online This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.
Open Source Security Myths Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual
property restrictions (or arrangement such as the public domain), and is
usually developed with the input of many contributors.
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.
Understanding Web Application Security Challenges This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.