<%
'declare your variables
Dim oConnection, sSQL, oRecordset
Dim iPage, iPagecount, iRecordcount
Dim iStart, ifinish, iRecord, i
'declare SQL statement that will query the database
sSQL = "SELECT * FROM qryGuestbook ORDER BY Date_Time DESC;"
'create ADO connection and recordset object
Set oConnection = Server.CreateObject("ADODB.Connection")
Set oRecordset = Server.CreateObject("ADODB.Recordset")
'Open the connection to the database
oConnection.Open(sConnString)
'Open the recordset object executing the SQL statement and returning the records
oRecordset.Cursorlocation=3
oRecordset.Cursortype=3
oRecordset.Open sSQL, oConnection
If Request.Querystring("NAV")="" then
iPage=1
Else
iPage=request.querystring("NAV")
End if
oRecordset.pagesize=10
iPagecount=oRecordset.pagecount
iRecordcount=oRecordset.recordcount
If Cint(iPage)>Cint(iPagecount) then iPage=iPagecount
If Cint(iPage)<=0 then iPage=1
If iRecordcount>0 then
oRecordset.absolutepage=iPage
iStart=oRecordset.absoluteposition
If Cint(iPage)=Cint(iPagecount) then
ifinish=iRecordcount
Else
ifinish=iStart+(oRecordset.pagesize-1)
End If
End If
'Check to see if there are any records with the End of File (EOF) property
If oRecordset.Eof Then
Response.write "
Sorry there are no Guestbook messages. Be the first to post!"
Else
Response.write "
"
If iRecordcount=1 Then
Response.write "There is 1 message"
Else
Response.write "There are " & iRecordcount & " messages"
End If
If iRecordcount >0 Then
Response.write " - Messages " & iStart & " through " & ifinish & " are displayed below."
Response.write "
"
End If
Response.write "
"
'As there are records lets loop through the records until we come to the end
For iRecord=1 to oRecordset.pagesize
Response.write "
"
Response.write "| Guest | " & oRecordset("FirstName") & " " & oRecordset("SurName") & " |
"
Response.write "| State & Country | " & oRecordset("StateCounty") & " - " & oRecordset("Country") & " |
"
Response.write "| Message | " & oRecordset("Message") & " |
"
Response.write "| Heard about Website | " & oRecordset("Heard_About_Website") & " |
"
Response.write "| Email | " & oRecordset("Email") & " |
"
Response.write "| Website | "
If Len(oRecordset("Website"))<7 Then
Response.write "Non-Applicable"
Else
Response.write oRecordset("Website")
End If
Response.write " |
"
Response.write "| Posted | " & oRecordset("Date_Time") & " |
"
Response.write "
"
Response.write "
"
'move on to the next record
oRecordset.movenext
If oRecordset.eof Then Exit For
Next
End if
For i=1 to oRecordset.pagecount
If i=Cint(iPage) then
Response.write "[Page"&i&"]"
Else
Response.write "[
Page "&i&"]"
End if
Next
'We are done so lets close the connection and the recordset
oRecordset.Close
Set oRecordset = Nothing
oConnection.Close
Set oConnection = Nothing
%>