Spooky's Databases >
Advanced Tips > Modify the DRW
Although the wizard is used to set up your DRW, the
code itself is actually quite customizable (in comparison to FP98!)
Here we have a look at the code, and what changing it
will probably result in.
Remember, any changes to the DRW code could render
that page useless or cause unreliable results. So as always keep a
backup!
Once changes are made, more often than not, you cannot reuse the DRW to
change simple formatting without rebuilding the whole DRW!
Other topics are :
Example code
To keep things simple, our example consists of a 1
cell table containing one field (RecordID) from the North wind database.
All we are demonstrating here, is what the code is
basically used for.
<table
width="100%"
border="1">
<thead>
<tr>
<td><b>ProductID</b></td>
</tr>
</thead>
<tbody>
What follows here, is the main code for querying the
database, and setting the display options.
Most of these options can be manually edited.
<!--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="<tr><td colspan=64 bgcolor="#FFFF00"
align="left" width="100%"><font color="#000000">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.</font></td></tr>"
preview="<tr><td colspan=64 bgcolor="#FFFF00" align="left"
width="100%"><font color="#000000">This is
the start of a Database Results region.</font></td></tr>"
-->
An include page is added.
This is the library of asp code that does some of the work.
<!--#include
file="_fpclass/fpdblib.inc"-->
The 'red' code below, is the generated asp code from
the DRW, and is passed to the include pages used to process the
variables. It CAN NOT be modified here, as the code
is generated by the web bot.
If you need to modify this code, you have 2 options.
1) Change the grey
code above
2) Use the Spooky diet
<%
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
%>
An include page is added
<!--#include
file="_fpclass/fpdbrgn1.inc"-->
Now we get into the actual page display code.
The first line signifies that the DRW is about to start.
<!--webbot bot="DatabaseRegionStart" i-CheckSum="25969" endspan -->
Our default setting that we have used is "Table", so a
row and cell are generated.
<tr>
<td>
The following gray code is used by the wizard to
format and display each database column record.
<!--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="<font size="-1">&lt;&lt;</font>ProductID<font
size="-1">&gt;&gt;</font>"
preview="<font size="-1">&lt;&lt;</font>ProductID<font
size="-1">&gt;&gt;</font>" -->
The red code below is again asp. It is the code that
does the actual work, writing the database value to the page.
<%=FP_FieldVal(fp_rs,"ProductID")%>
Now we close this cell and then we close the row
<!--webbot
bot="DatabaseResultColumn" i-CheckSum="17683"
endspan -->
</td>
</tr>
We tell the DRW we are finished with this row, and if
any more are to follow, we will loop through them until finished.
Otherwise, display the footer.
<!--webbot bot="DatabaseRegionEnd"
startspan
b-tableformat="TRUE"
b-menuformat="FALSE"
u-dbrgn2="_fpclass/fpdbrgn2.inc"
i-groupsize="5"
clientside tag="TBODY"
local_preview="<tr><td colspan=64 bgcolor="#FFFF00"
align="left" width="100%"><font color="#000000">This
is the end of a Database Results region.</font></td></tr><TR><TD
ALIGN=LEFT VALIGN=MIDDLE COLSPAN=64><FORM><NOBR><INPUT
TYPE=Button VALUE=" |< "><INPUT TYPE=Button VALUE="
< "><INPUT TYPE=Button VALUE=" > "><INPUT
TYPE=Button VALUE=" >| "> [1/5]</NOBR></FORM></td></tr>"
preview="<tr><td colspan=64 bgcolor="#FFFF00" align="left"
width="100%"><font color="#000000">This is
the end of a Database Results region.</font></td></tr><TR><TD
ALIGN=LEFT VALIGN=MIDDLE COLSPAN=64><NOBR><INPUT TYPE=Button
VALUE=" |< "><INPUT TYPE=Button VALUE=" < "><INPUT
TYPE=Button VALUE=" > "><INPUT TYPE=Button VALUE="
>| "> [1/5]</NOBR><BR></td></tr>" -->
And the final include page is added
<!--#include
file="_fpclass/fpdbrgn2.inc"-->
<!--webbot bot="DatabaseRegionEnd" i-CheckSum="62730" endspan -->
</tbody>
</table>
|