Search Search

#1 worldwide
FREE Coding Lessons

since 1996
   THE BEST WAY to learn ASP & Asp.net!
Advertise Here!
click for details
Credits Host:
DiscountASP.net
Server Admin:
The "Team"
Contact Info.
Charles M. Carroll

my Blog
[prev. Lesson]  RSFast: caching Method Explained
     [next Lesson]  RSFast: Commands

Overview: RSFast - Error Checking
by Charles Carroll

The library Rsfast reports errors encountered. The messages do not contain all details by default (so as to not expose sensitive DSN and Query data for example) but those details can be turned on. The error messages can be customized via their name as this sample shows:

   filename=/learn/rsfast_current/rsfast-errors-test.asp

<Test Script Below>


<%@ enablesessionstate=false%>
<%option explicit%>
<%
response.buffer=true
server.scripttimeout=40
%>
<!--#include file="lib_rsfast.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>rsfast-templates</title>
</head>
<body bgcolor="#FFFFFF">
<%
    dim rsparms,conntest,separator
    separator="<hr><br>"
    set rsparms=server.CreateObject("Scripting.Dictionary")

    rsparms.add "debug", true
   rsparms.add "template_header", "<table border=1>"
   rsparms.add "template_row_header", "<tr>"
   rsparms.add "template_row_footer", "</tr>"
   rsparms.add "template_col_header", "<td>"
   rsparms.add "template_col_footer", "</td>"
   rsparms.add "template_footer", "</table>"
   rsparms.add "fieldnull", "&nbsp;"
   rsparms.add "fieldblank", "&nbsp;"
   rsparms.add "fld_city", "<td bgcolor='lightblue'><b>{0}</b><br></td>"
   rsparms.add "fld_state", "<td><b>{0}</b><br></td>"   
   rsparms.add "colnames", "display"   
   
   ' Bad DSN
   rsparms.Add "conn", "DSN=xxx;uid=student;pwd=magic"
   rsparms.add "sql", "select * from publishers where state='NY'"
   Call RsFast(rsparms)
   response.write separator
   
   ' Bad DSN, detailed error
   rsparms.item("errorsdetailed")=true
    Call RsFast(rsparms)
   response.write separator

    ' Bad DSN, customerror
    rsparms.item("error_dsn_bad")="I don't like that DSN!!!!"
    Call RsFast(rsparms)
    response.write separator

    ' Bad DSN, customerror, more details
    rsparms.item("error_dsn_bad")="I don't like that DSN!!!! {details}"
    Call RsFast(rsparms)
    response.write separator
    
    ' Bad DSN login info
    rsparms.item("conn")="DSN=student;uid=xxx;pwd=xxx"
    rsparms.item("errorsdetailed")=true
    Call RsFast(rsparms)   
    response.write separator

    rsparms.item("conn")="DSN=student;uid=student;pwd=magic"

    ' Bad Query 1
    rsparms.item("sql")="Select ^ from pubs where state='NY'"
    rsparms.item("errorsdetailed")=true
    Call RsFast(rsparms)   
    response.write separator

    ' Bad Query 2
    rsparms.item("sql")="Select * from pubs where state='NY'"
    rsparms.item("errorsdetailed")=true
    Call RsFast(rsparms) 
    response.write separator

    ' Bad Query 3
    rsparms.item("sql")="Select * from publishers where st='NY'"
    rsparms.item("errorsdetailed")=true
    Call RsFast(rsparms) 
    response.write separator
     
    ' Query That Results in EOF
    rsparms.item("sql")="Select * from publishers where state='ZZ'"
    rsparms.item("errorsdetailed")=true
    Call RsFast(rsparms) 
    response.write separator

    ' Empty SQL statement
    rsparms.item("sql")=""
    rsparms.item("errorsdetailed")=true
    Call RsFast(rsparms) 
    response.write separator
    
    ' Unknown Errors
    rsparms.item("sql")="a"
    rsparms.item("errorsdetailed")=true
    Call RsFast(rsparms) 
    response.write separator
 

    set rsparms=nothing
%>
</body>
</html>

The library file that does all the work is at:
http://www.learnasp.com/freebook/asp/rsfast-lib.aspx
so go there to cut and paste the include file if needed.

There are many worthy charities!!. But perhaps help starving children in Africa or South America AND help Charles too. a $5 tip buys him lunch at McDonalds, a $20 tip buys his kid Hitoshi a new computer game, a $39 tip buys his daughter Michiko a few nice outfits. See our donor list.