navigation
Thomas Brunt's OutFront Hosting
 
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Microsoft MVP
 

Spooky's Databases > Modify the DRW > Spooky Diet


The code relies a lot on the web bot code to regenerate the Wizard that defines the DRW.
Whilst this code is necessary when you are developing code, you may find it no longer serves any purpose afterwards.

Why bother put the code on a diet then?

Well, page size is the main reason.
I've seen basic database results pages that weigh in at 500 - 1000 k (One meg!)

The general rule of thumb, is to not make the user download more than 20 - 100k. Otherwise, they may get tired of waiting and leave. Ever tried waiting for a 1000k page to display via Modem? Yep.....

This extra code size, or "bloat" is caused by the repetition of the Wizard code FOR EACH LINE.
In the Spooky Diet, I'll show you how to reduce the outputted code size by a large amount!

The example below, is only a simple "one column" database, but the code size is reduced from 20k to 2k!!
Imagine the advantages as you add more columns and more lines!


Here we use our previous example. Note, obviously, that your code may appear slightly different, BUT the code that is left, will always be the same. The only code that varies, is the code we will remove.

DISCLAIMER!!
Always keep a copy of the page you are about to modify. Spooky will not be responsible for the frustration of deleting something with out having a backup! (Much like me rewriting this page now, but that's a different story....)

<table width="100%" border="1">
<thead>
<tr>
<td><b>
ProductID</b></td>
</tr>
</thead>
<tbody>

Here's the first piece of code below that's not required. Delete it!

<SNIP>

<!--webbot bot="DatabaseRegionStart" startspan
s-columnnames="ProductID,ProductName,SupplierID,CategoryID,
QuantityPerUnit,UnitPrice,UnitsInStock,UnitsOnOrder
,ReorderLevel,Discontinued"
s-columntypes="3,200,3,3,200,6,2,2,2,11"
s-dataconnection="Sample"
b-tableformat="TRUE"
menuformat="FALSE"
s-menuchoice
s-menuvalue
b-tableborder="TRUE"
b-tableexpand="TRUE"
b-tableheader="TRUE"
b-listlabels="TRUE"
b-listseparator="TRUE"
i-ListFormat="6"
b-makeform="FALSE"
s-recordsource="Products"
s-displaycolumns="ProductID"
s-criteria s-order s-sql="SELECT * FROM Products"
b-procedure="FALSE"
clientside SuggestedExt="asp"
s-DefaultFields
s-NoRecordsFound="No records returned."
i-MaxRecords="256"
i-GroupSize="5"
BOTID="0"
u-dblib="_fpclass/fpdblib.inc"
u-dbrgn1="_fpclass/fpdbrgn1.inc"
u-dbrgn2="_fpclass/fpdbrgn2.inc"
tag="TBODY"
local_preview="&lt;tr&gt;&lt;td colspan=64 bgcolor=&quot;#FFFF00&quot; align=&quot;left&quot; width=&quot;100%&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;Database Results regions will not preview unless this page is fetched from a Web server with a web browser. The following table row will repeat once for every record returned by the query.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;"
preview="&lt;tr&gt;&lt;td colspan=64 bgcolor=&quot;#FFFF00&quot; align=&quot;left&quot; width=&quot;100%&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;This is the start of a Database Results region.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;" -->

</SNIP>

This code MUST stay. It's the include file that does all the work, and shows the asp variables that you can now manually edit.

<!--#include file="_fpclass/fpdblib.inc"-->

<%
fp_sQry="SELECT * FROM Products"
fp_sDefault=""
fp_sNoRecords="<tr><td colspan=1 align=left width=""100%"">No records returned.</td></tr>"
fp_sDataConn="Sample"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=5
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_iDisplayCols=1
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>

<!--#include file="_fpclass/fpdbrgn1.inc"-->

Here's the next piece of code to go. Delete it!

<SNIP>

<!--webbot bot="DatabaseRegionStart" i-CheckSum="25969" endspan -->

</SNIP>

<tr>
<td>

Each ROW of the DRW contains DRW code. It can all be removed and only leave the RED code

<SNIP>

<!--webbot bot="DatabaseResultColumn" startspan
s-columnnames="ProductID,ProductName,SupplierID,CategoryID
,QuantityPerUnit,UnitPrice,UnitsInStock,
UnitsOnOrder,ReorderLevel,Discontinued"
s-column="ProductID"
b-tableformat="TRUE"
b-hasHTML="FALSE"
clientside
local_preview="&lt;font size=&quot;-1&quot;&gt;&amp;lt;&amp;lt;&lt;/font&gt;ProductID&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;"
preview="&lt;font size=&quot;-1&quot;&gt;&amp;lt;&amp;lt;&lt;/font&gt;ProductID&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" -->

<%=FP_FieldVal(fp_rs,"ProductID")%>   <-- This code must stay!!

<!--webbot bot="DatabaseResultColumn" i-CheckSum="17683" endspan -->

</SNIP>

</td>
</tr>

Now we finish the region by removing all of the footer information.

<SNIP>

<!--webbot bot="DatabaseRegionEnd" startspan
b-tableformat="TRUE"
b-menuformat="FALSE"
u-dbrgn2="_fpclass/fpdbrgn2.inc"
 i-groupsize="5"
clientside tag="TBODY"
local_preview="&lt;tr&gt;&lt;td colspan=64 bgcolor=&quot;#FFFF00&quot; align=&quot;left&quot; width=&quot;100%&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;This is the end of a Database Results region.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;TR&gt;&lt;TD ALIGN=LEFT VALIGN=MIDDLE COLSPAN=64&gt;&lt;FORM&gt;&lt;NOBR&gt;&lt;INPUT TYPE=Button VALUE=&quot; |&lt; &quot;&gt;&lt;INPUT TYPE=Button VALUE=&quot; &lt; &quot;&gt;&lt;INPUT TYPE=Button VALUE=&quot; &gt; &quot;&gt;&lt;INPUT TYPE=Button VALUE=&quot; &gt;| &quot;&gt; [1/5]&lt;/NOBR&gt;&lt;/FORM&gt;&lt;/td&gt;&lt;/tr&gt;"
preview="&lt;tr&gt;&lt;td colspan=64 bgcolor=&quot;#FFFF00&quot; align=&quot;left&quot; width=&quot;100%&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;This is the end of a Database Results region.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;TR&gt;&lt;TD ALIGN=LEFT VALIGN=MIDDLE COLSPAN=64&gt;&lt;NOBR&gt;&lt;INPUT TYPE=Button VALUE=&quot; |&lt; &quot;&gt;&lt;INPUT TYPE=Button VALUE=&quot; &lt; &quot;&gt;&lt;INPUT TYPE=Button VALUE=&quot; &gt; &quot;&gt;&lt;INPUT TYPE=Button VALUE=&quot; &gt;| &quot;&gt; [1/5]&lt;/NOBR&gt;&lt;BR&gt;&lt;/td&gt;&lt;/tr&gt;" -->

</SNIP>

You MUST still leave the include file below
Note, it is usually at the end of the code above, don't delete it by mistake!

<!--#include file="_fpclass/fpdbrgn2.inc"-->

And delete the last line

<SNIP>

<!--webbot bot="DatabaseRegionEnd" i-CheckSum="62730" endspan -->

</SNIP>

</tbody>
</table>


So, our finished code looks something like this!
 

<table width="100%" border="1">
<thead>
<tr>
<td><b>
ProductID</b></td>
</tr>
</thead>
<tbody>

<!--#include file="_fpclass/fpdblib.inc"-->

<%
fp_sQry="SELECT * FROM Products"
fp_sDefault=""
fp_sNoRecords="<tr><td colspan=1 align=left width=""100%"">No records returned.</td></tr>"
fp_sDataConn="Sample"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=5
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_iDisplayCols=1
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>

<!--#include file="_fpclass/fpdbrgn1.inc"-->

<tr>
<td>

<%=FP_FieldVal(fp_rs,"ProductID")%>

</td>
</tr>

<!--#include file="_fpclass/fpdbrgn2.inc"-->
</tbody>
</table>

 

However, there is a slightly easier way!
Stephen Travis, MVP for FrontPage, wrote this macro for us which achieves the same thing.
It will automate and speed up the task quite substantially.

 


Microsoft Corporation in no way endorses or is affiliated with "OutFront." 
OutFront is published and edited by Thomas Brunt
440 Great Circle Dr., St. Matthews, SC 29135.  803-655-6151
© 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 All Rights Reserved
Click here to view our privacy statement.