Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Help!


Message #1 by stephanieweigel@y... on Sun, 21 Apr 2002 22:54:50
I am having a few problems, here is the first one. I have a table called 
Events that I want to list on a page all events that have the maxmum 
number of attendees (30). Here is my code


<%Dim objconn, objrs
Set objconn= Server.CreateObject("ADODB.Connection")
Set objrs = Server.CreateObject("ADODB.Recordset")
objconn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data 
Source=C:\Inetpub\wwwroot\Final\eventRegistration.mdb;Persist Security 
Info=False"
objrs.open "Select * FROM Events Where NumberofAttendees = 30"
If objrs.eof then
	Response.write "There are currently no events that are full"
Else
    Response.Write _
      "<TABLE BORDER=""1"" CELLSPACING=""3"" CELLPADDING=""3"">" & _
      "  <TR>" & _
      "    <TH>Place" 
             Response.Write "</TH>" & _
      "    <TH>EventDate</TH>" & _
      "    <TH>EventTime</TH>" & _
      "    <TH>Place</TH>" & _
      "    <TH>Description</TH>" & _
      "    <TH>NumberofAttendees</TH>" & _
      "  </TR>"
	Do While NOT objrs.eof
		Response.Write "<TR ALIGN=CENTER>"
		Response.Write _ 
        "<TD>" & objrs("Place") & "</TD>" & _ 
        "<TD>" & objrs("EventDate") & "</TD>" & _
        "<TD>" & objrs("EventTime") & "</TD>" & _ 
        "<TD>" & objrs("Description") & "</TD>" & _
        "<TD>" & objrs("NumberofAttendees") & "</TD>" & _ 

      "</TR>"
      objrs.MoveNext
    Loop
    Response.Write "</TABLE>"
    objrs.close
    Set objrs = Nothing
End If
%>

I get the following error:
Error Type:
ADODB.Recordset (0x800A0E7D)
The connection cannot be used to perform this operation. It is either 
closed or invalid in this context.
/final/MaxAttend.asp, line 15


Line is the the line with my Select statement. Any ideas what I am doing 
wrong?

Thanks!
Message #2 by "Kim Iwan Hansen" <kimiwan@k...> on Mon, 22 Apr 2002 00:07:56 +0200
looks to me like you're forgetting to specify the connection string/object
in your objrs.open line

---
objrs.open "Select * FROM Events Where NumberofAttendees = 30"

should be

objrs.open "Select * FROM Events Where NumberofAttendees = 30", objconn
---

-Kim


-----Original Message-----
From: stephanieweigel@y... [mailto:stephanieweigel@y...]
Sent: 21. april 2002 22:55
To: ASP Databases
Subject: [asp_databases] Help!


I am having a few problems, here is the first one. I have a table called
Events that I want to list on a page all events that have the maxmum
number of attendees (30). Here is my code


<%Dim objconn, objrs
Set objconn= Server.CreateObject("ADODB.Connection")
Set objrs = Server.CreateObject("ADODB.Recordset")
objconn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Inetpub\wwwroot\Final\eventRegistration.mdb;Persist Security
Info=False"
objrs.open "Select * FROM Events Where NumberofAttendees = 30"
If objrs.eof then
	Response.write "There are currently no events that are full"
Else
    Response.Write _
      "<TABLE BORDER=""1"" CELLSPACING=""3"" CELLPADDING=""3"">" & _
      "  <TR>" & _
      "    <TH>Place"
             Response.Write "</TH>" & _
      "    <TH>EventDate</TH>" & _
      "    <TH>EventTime</TH>" & _
      "    <TH>Place</TH>" & _
      "    <TH>Description</TH>" & _
      "    <TH>NumberofAttendees</TH>" & _
      "  </TR>"
	Do While NOT objrs.eof
		Response.Write "<TR ALIGN=CENTER>"
		Response.Write _
        "<TD>" & objrs("Place") & "</TD>" & _
        "<TD>" & objrs("EventDate") & "</TD>" & _
        "<TD>" & objrs("EventTime") & "</TD>" & _
        "<TD>" & objrs("Description") & "</TD>" & _
        "<TD>" & objrs("NumberofAttendees") & "</TD>" & _

      "</TR>"
      objrs.MoveNext
    Loop
    Response.Write "</TABLE>"
    objrs.close
    Set objrs = Nothing
End If
%>

I get the following error:
Error Type:
ADODB.Recordset (0x800A0E7D)
The connection cannot be used to perform this operation. It is either
closed or invalid in this context.
/final/MaxAttend.asp, line 15


Line is the the line with my Select statement. Any ideas what I am doing
wrong?

Thanks!


  Return to Index