|
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
<%@ 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", " "
rsparms.add "fieldblank", " "
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
<%@ 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.
 |  |  |
 |
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.
|  |
 |  |  |
|
|
|
|