vb logo

 

Visual Basic Books
Home
Visual Basic Beginner Books
Visual Basic Database Books
Visual Basic ActiveX Books
Visual Basic Advanced Books
VB Internet Programming Books

Resources
Visual Basic Links
Add a Link
Subscribe to Mailing List

Visual Basic Books

Back Contents Next

Exercises

These exercises use one or both of the two sample databases available from the Wrox Press website, at http://webdev.wrox.co.uk/books/2726. Appendices A and B contain a description of the structure of (respectively) the Sailors database and the Clothier database.

 

1 Use Sailor.mdb to create a list of sailors with one sailor per line (no table)

2 Use Sailor.mdb to create a table of all of the boats.

3 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

%>

 

 

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>

 

 

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

%>

 

 


Back Contents Next
©1999 Wrox Press Limited, US and UK.
Email us your comments:mail
Fax: 1(916)404-7719
©1999-2000 Visual Basic Books. All rights reserved.