sail3005
Mar 11th, 2001, 08:07 PM
I am trying to make just a very simple guestbook to fiddle around with. I want to read from the records in reverse so that the newest entry appears on top. This code gives me errors:
I set it to go to the last record, and then tell the loop to go backwards, but i get errors. Can anyone help me accomplish this task? Here is the code:
<%
Dim objRS, strName, strComment
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open "main", objConn, , adLockOptimistic, adCmdTable
strName = Request.Form("name")
strComment = Request.Form("comment")
objRS.AddNew
objRS("Name") = strName
objRS("Message") = strComment
objRS.Update
objRS.MoveLast
If objRS.EOF Then
Response.Write "Database is empty"
Else
Do While Not objRS.EOF
Response.Write "<pre>"
Response.Write "Name: " & objRS("Name") & "<br>"
Response.Write "Comment: " & objRS("Message") & "<br>"
Response.Write "<hr><p>"
Response.Write "</pre>"
objRS.MovePrevious
Loop
End If
objRS.Close
Set objRS = Nothing
objConn.Close
Set objConn = Nothing
%>
I set it to go to the last record, and then tell the loop to go backwards, but i get errors. Can anyone help me accomplish this task? Here is the code:
<%
Dim objRS, strName, strComment
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open "main", objConn, , adLockOptimistic, adCmdTable
strName = Request.Form("name")
strComment = Request.Form("comment")
objRS.AddNew
objRS("Name") = strName
objRS("Message") = strComment
objRS.Update
objRS.MoveLast
If objRS.EOF Then
Response.Write "Database is empty"
Else
Do While Not objRS.EOF
Response.Write "<pre>"
Response.Write "Name: " & objRS("Name") & "<br>"
Response.Write "Comment: " & objRS("Message") & "<br>"
Response.Write "<hr><p>"
Response.Write "</pre>"
objRS.MovePrevious
Loop
End If
objRS.Close
Set objRS = Nothing
objConn.Close
Set objConn = Nothing
%>