%
' Start ASP code here before the HTML. Its always better to do as much ASP stuff before any output.
' First of all, include a simple file which contains some variable values.
%>
<%
' Now some values have been set we can use them to connect to the Access database
' First, build a SQL query to get the data we want.
sql = "Select placeText, placeID from tblPlaces order by placeText ASC"
' Now create a record set to hold the data. "conString" is the connection string and is a variable which has it's
' value set in the include "vars.htm" file on line .
' Line 20 opens the recordset which I've imaginatively called "rsContent". rs being Record Set obviously ;}
set rsContent = Server.CreateObject("ADODB.Recordset")
rsContent.ActiveConnection = conString
rsContent.Source = sql
rsContent.CursorType = 3
rsContent.CursorLocation = 2
rsContent.LockType = 1
rsContent.Open()
' Now we have some data from the data base, we need to output it to screen.
' First, get the basic HTML stuff out of the way
%>
Peter Ellegard - International Freelance Travel Writer and Photographer
Images Available
I have 35mm and medium format transparencies plus digital images in the following continents/subject areas.
Click on one for details
<%
' now its the place to spit out our data to the screen.
' The easiest way is a "While" loop.
' This will run while the rsContent hasn't reached EOF End of File.
' i.e. it will work through all the records in the record set and stop when it runs out.
While (NOT rsContent.EOF)
' The next line prints a link using the database field "placeText" which is, of course, stored
' in the record set object "rsContent". The link is to a file called showPlaces.htm and includes
' an id in the querystring. This is the primary key for the database record. We're passing it to
' the showPlaces file so it know which record to look up.
%>
"><%=(rsContent.Fields.Item("placeText").Value)%>
<%
' Move to the next record in the record set. Otherwise it would repeat the same record forever
' because it would never reach the end of file.
rsContent.movenext()
Wend
' Now we're done with the record set object rsContent. Its VERY important that we now close the connection
' to the database and destroy the object. This stuff uses CPU/Memory and if you don't "tidy up" the code
' will hog resources unnecesarily.
rsContent.Close()
Set rsContent = Nothing
' Done :)
%>
<%
' Now we have to cheat a bit because the coords are so specific its trickey to generate
' these links dynamically.
' One solution would be to place the COORDS into the database recrod but that would
' require Peter to enter the correct numbers. Its best not to rely upon users ;}
' SO.... We cheat and hard code the links with the right IDs here.
' This is "not a good thing" generally but there's no way around it
' The ID can be found by either looking in the database or, more simply,
' hovering over the links generated above. For example, The Africa link is
' showPlaces.htm?id=4 which you can see in the status bar when you hover over it.
%>