p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

proasp_codeclinic thread: Cannot Connect to Database (Same Problem)


Message #1 by "Bob" <bobage24@a...> on Tue, 19 Sep 2000 16:52:51 +0100
Two things:
1) remove the smi-colon from the end of the SQL statement (I've not put them
there, but it may be OK).
2) check the data base for "rows" in the table, because you are telling it
to print the results BEFORE you verify that any rows were returned.  I
suspect that you are not getting any rows returned.

-----Original Message-----
From: Bob [mailto:bobage24@a...]
Sent: Tuesday, September 19, 2000 8:53 AM
To: Code Clinic
Subject: [proasp_codeclinic] Cannot Connect to Database (Same Problem)


OK, I think I got rid of the typos, but I am still having trouble with
getting the code right. Here is the Code:

<% OPTION EXPLICIT %>
<!--#include file="Clssfd.asp"-->
<BASEFONT FACE="Comic Sans MS" COLOR="DarkBlue">
<HTML>
<HEAD>
<TITLE>The Gym Directory - Adding Comments</TITLE>
</HEAD>

<BODY BGCOLOR="#FFFFFF">
<%                        'This code works fine:::::
  Dim rsItem, strItemName, strDescription, strAddress
  Set rsItem = Server.CreateObject("ADODB.Recordset")
  strSQL = "SELECT * FROM Gym WHERE ID =" & Request("Gym")
  rsItem.Open strSQL, objConn
  strItemName = rsItem("GymName")
  strAddress = rsItem("Address")
  strDescription = rsItem("Description")
  rsItem.Close
  Set rsItem = Nothing

              'Here is where the problems start::::
  
  Dim rsComments, strComments
  Set rsComments = Server.CreateObject("ADODB.Recordset")
  strSQL = "SELECT * FROM Comments WHERE ID =" & Request("Gym") & _
           " ORDER BY TimeStamp DESC;"
  rsComments.Open strSQL, objConn
  Set strComments = rsComments("Comments")
  Response.Write strComments      "This line is causing an error which is
at the bottom of the page.

%>
<CENTER><H1>The Gym Directory<BR>Adding comments to <%= strItemName
%></H1></CENTER>
<P>
   'This next section is still not working at all::::
<%
  If rsComments.EOF Then
    Response.Write "So far no comments have been added."
  Else
    Response.Write _
      "<TABLE BORDER=""2"" WIDTH=100% CELLSPACING=""3"">" & _
      "<TR>" & _
      "  <TH>Comments</TH>" & _
      "  <TH>Added</TH>" & _
      "</TR>"
  Do While Not rsComments.EOF
     Response.Write _
      "<TR>" & _
      " <TD>" & rsComments("Comments") & "</TD>" & _
      " <TD>" & rsComments("TimeStamp") & "</TD>" & _
      "</TR>"
      rsComments.MoveNext
    Loop
    End If
    Response.Write "</TABLE>"
    rsComments.Close
    Set rsComments = Nothing 
 
%>

Now here is the error I am getting???? I get it when I do Response.Write
strComments. What does the error mean?? I am trying to get the Comments
for the Current gym listing and list them all on the page. I can't seem to
get it to work. Any help is greatly appreciated. Here is the error code I
am now getting:


ADODB.Field error '80020009' 

Either BOF or EOF is True, or the current record has been deleted.
Requested operation requires a current record.

? 

Thanks Again,
Bob


  Return to Index