Exercises - Page 13
November 27, 2000
These exercises use one or both of the two sample databases
available from the Wrox Press website, at
http://www.wrox.com/Books/Book_down.asp?section=11_3&isbn=1861002726&subject=&subject_id.
Appendices A and B contain a description of the structure of
(respectively) the Sailors database and the
Clothier database.
- Use
Sailor.mdb to create a list of sailors with
one sailor per line (no table)
- Use
Sailor.mdb to create a table of all of the
boats.
- Use
Sailor.mdb to make a list of the yacht
clubs; not in a table but separated by horizontal lines.
Exercises - Answers
Note: answers are also presented in C01-Exercise.asp available
from the WROX site.
1. Use Sailors.mdb to create a list of
sailors with one sailor per line (no table).
<H1>Chapter 3 Simple Recordsets</h1>
<H3>Exercise 1 Use Sailors.mdb to create a list of sailors with
one sailor per line</H3>
<%
dim oRSp
Set oRSp=server.CreateObject("ADODB.recordset")
oRSp.open "People", "DSN=sailors"
do while not oRSp.EOF
Response.Write oRSp("PeopleNameFirst") & " "
Response.Write oRSp("PeopleNameLast") & "<BR>"
oRSp.movenext
loop
%>
[Note: the 2nd and 3rd lines above have been split for
formatting purposes]
2. Use Sailors.mdb to create a table of all
of the boats.
<H1>Chapter 3 Simple Recordsets</h1>
<H3>Exercise 2 Use Sailors.mdb to create
a table of all the boats</H3>
<TABLE BORDER="1">
<%
dim oRSb
Set oRSb=server.CreateObject("ADODB.recordset")
oRSb.open "Boats", "DSN=sailors"
do while not oRSb.EOF
Response.Write "<TR><TD>" & oRSb("BoatName") & "</TD>"
Response.Write "<TD>" & oRSb("BoatClass") & "</TD></TR>"
oRSb.movenext
loop
oRSb.close
set oRSb=nothing
%>
</TABLE>
[Note: the 2nd and 3rd lines above have been split for
formatting purposes]
3. Use Sailors.mdb to make a list of the
yacht clubs; not in a table but separated by horizontal lines.
<H1>Chapter 3 Simple Recordsets</h1>
<H3>Exercise 3 Use Sailors.mdb to make a list
of the yacht clubs; not in a table</H3>
<%
dim oRSyc
Set oRSyc=server.CreateObject("ADODB.recordset")
oRSyc.open "Clubs", "DSN=sailors"
do while not oRSyc.EOF
Response.Write "<hr>" & oRSyc("ClubName") & "</TD>"
oRSyc.movenext
loop
Response.Write "<hr>"
oRSyc.close
set oRSyc=nothing
%>
[Note: the 2nd and 3rd lines above have been split for
formatting purposes]
A Trap With Recordsets and Tables - Page 12
Beginning ASP Databases
Chapter Three Quiz - Page 14
|