|
<%
Dim strSQL, recCounter, fldValue, strOut, db, rs, rsCount, fullName, strDate, strPersonDetail, strCity, strCountry
Dim bCityExists, strMessage
strSQL = "select dateReply, surname, firstname, city, country, message "
strSQL = strSQL & "from tblGuestbook "
strSQL = strSQL & "Order By surname"
strSQL = strSQL & ";"
recCounter = 0
strOut = ""
Set rs = Server.CreateObject("ADODB.Recordset")
'Turn On Error Handling
On Error Resume Next
rs.Open strSQL, con
con.Execute strSQL
If err.number > 0 then
If CStr(err.nativeerror) = "2013" or CInt(err.nativeerror) = 2013 Then
con.Close
Set con=nothing
%>
<%
Else
response.write "VBScript Errors Occured:" & " "
response.write "Error Number=" & err.number & " "
response.write "Error Descr.=" & err.description & " "
response.write "Help Context=" & err.helpcontext & " "
response.write "Help Path=" & err.helppath & " "
response.write "Native Error=" & err.nativeerror & " "
response.write "Source=" & err.source & " "
response.write "SQLState=" & err.sqlstate & " "
con.Close
Set con=nothing
End If
Else
If Not rs.EOF Then
rs.MoveFirst
%>
<%
Do Until rs.EOF
recCounter = recCounter + 1
strOut = strOut & vbTab & "" & vbCrLf
strOut = strOut & vbTab & "" & vbCrLf
fullName = "From " & RS("firstname") & " " & RS("surname")
strDate = CStr(RS("dateReply"))
strDate = Left(strDate, instr(1, strDate, " ") - 1)
strCity = RS("city")
If IsNull(strCity) or IsEmpty(strCity) or strCity="" Then
strCity = " "
bCityExists = False
Else
bCityExists = True
End If
strCountry = RS("country")
If IsNull(strCountry) or IsEmpty(strCountry) or strCountry="" Then
strCountry= " "
Else
If bCityExists = True Then
strCountry = ", " & strCountry
End If
End If
strPersonDetail = fullName & " on " & strDate & " " & strCity & strCountry
strOut = strOut & vbTab & vbTab & ""
strOut = strOut & strPersonDetail & " | " & vbCrLf
strOut = strOut & vbTab & " " & vbCrLf
strMessage = CStr(RS("message"))
strMessage = replace(strMessage,vbcrlf," ")
strOut = strOut & vbTab & "" & vbCrLf
strOut = strOut & vbTab & vbTab & ""
strOut = strOut & strMessage & " | " & vbCrLf
strOut = strOut & vbTab & " "
strOut = strOut & vbTab & " " & vbCrLf
strOut = strOut & vbTab & " " & vbCrLf
If recCounter = 10 Then
recCounter = 0
response.write(strOut)
strOut = ""
End If
rs.MoveNext
Loop
Else
%>
No messages in guest book at this time |
<%
End If
If recCounter > 0 Then
response.write(strOut)
strOut = ""
End If
rs.Close
con.Close
Set con = Nothing
End If
%>
|