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: Templates for any look Fast
     [next Lesson]  RSFast: RSFast: Performance Data

RSFast - MS Access, Templates Example
by Charles Carroll

The library RSFast can use a template you supply to format data any way, and can make an OLEDB connection to an Access file (and map the path) if you just supply the access filename. It is also highly recommended caching (see http://www.learnasp.com/learn/rsfast-cache.asp) be used with Access to reduce database access and increase scalability. Here is the sample code to display a customized table:

   filename=/learn/rsfast_current/rsfast-access.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
    set rsparms=server.CreateObject("Scripting.Dictionary")
   rsparms.item("cachename")="nwcust"
   rsparms.item("cachemin")=5

   ' Can be supplied as virtual
   rsparms.Add "accdb", "/learn/test/nwind.mdb"
   
   ' Or literal
   ' rsparms.Add "accdb", "D:\Webs\Learnasp\www\learn\test\nwind.mdb"
   
   ' either of the above works
   
   'rsparms.add "debug", true
   rsparms.add "sql", "select * from customers"
   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_country", "<td bgcolor='lightblue'><b>{0}</b><br></td>"
   rsparms.add "fld_companyname", "<td><b>{0}</b><br></td>"
   rsparms.add "fld_contactname", "<td><b>{0}</b><br></td>"

   rsparms.add "colnames", "display"   
   Call RsFast(rsparms)
   'Call PerfDisplay(rsparms)
    set rsparms=nothing
%>
</body>
</html>

Here is the sample code to display several listboxes:

   filename=/learn/rsfast_current/rsfast-access-lists.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
    set rsparms=server.CreateObject("Scripting.Dictionary")
   rsparms.item("cachename")="nwcust"
   rsparms.item("cachemin")=5

   ' Can be supplied as virtual
   rsparms.Add "accdb", "/learn/test/nwind.mdb"
   
   ' Or literal
   ' rsparms.Add "accdb", "D:\Webs\Learnasp\www\learn\test\nwind.mdb"
   
   ' either of the above works
   
   rsparms.add "sql", "select distinct city from customers"
   rsparms.add "template", "list"
    rsparms.add "templatename", "city"
    rsparms.item("cachename")="nwindcity"
   rsparms.item("cachemin")=30
   response.write "City: "
   Call RsFast(rsparms)
   response.write "<br>"
   response.flush

   rsparms.item("sql")="select distinct region from customers"
   rsparms.item("templatename")="region"
   rsparms.item("cachename")="nwindregion"
   rsparms.item("cachemin")=30
   response.write "Region: "
   Call RsFast(rsparms)
   response.write "<br>"
   response.flush

   rsparms.item("sql")="select distinct country from customers"
   rsparms.item("templatename")="country"
   rsparms.item("cachename")="nwindcountry"
   rsparms.item("cachemin")=30
   response.write "Country: "
   Call RsFast(rsparms)
   response.write "<br>"
   'Call PerfDisplay(rsparms)
    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.

Chaz Wish List
Tall Tip $5
Grande Tip $20
Venti Tip $39
Tip Jar Thanks
2004 Thanks
2005 Thanks
HUGE Tip -love site