Wrox Programmer Forums
|
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 31st, 2006, 05:52 AM
Authorized User
 
Join Date: May 2006
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Default Object Closed Error

Hi,
I get the following message:
Error Type:
ADODB.Recordset (0x800A0E78)
Operation is not allowed when the object is closed.
/MiddlePath/testC.asp, line 70

Code:
If Request.Form("minAge") <> "" THEN
    intAgemin = CInt(Request.Form("minAge"))
    intAgemax = CInt(Request.Form("maxAge"))
    mySQLmin = "SELECT * FROM tbl_brother WHERE BrAge BETWEEN " & intAgemin & " AND " & intAgemax & ";"
myRS.Open mySQLmin, myCon,3,3,1
ELSE
Response.write "Nothing selected"
End IF
...
<%
myRS.AbsolutePage = intPage 'Line 70
For intRecord = 1 To myRS.PageSize %>
Any clues as to what I need to correct :)


 
Old July 31st, 2006, 08:37 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

You dont have a connection open between your app and the database.

"The one language all programmers understand is profanity."
 
Old July 31st, 2006, 09:27 AM
Authorized User
 
Join Date: May 2006
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dims & Connections are all above...:)

What other code should i show that may help?

 
Old July 31st, 2006, 12:41 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Well here is the thing, you call myRS.Open inside an IF statement which means the connection may or may not open, however, you call myRS.AbsolutePage outside of the if which, by design, you expect the connection to be open 100% of the time.

Is your primary if firing?

A better way to do this would be something like this:

If request.form("minAge") <> "" then
    intAgemin = CInt(Request("minAge"))
    intAgemax = CInt(Request("maxAge"))
    mySQLmin = "SELECT * FROM tbl_brother WHERE BrAge BETWEEN " & intAgemin & " AND " & intAgemax & ";"
    myRS.Open mySQLmin, myCon,3,3,1
    myRS.AbsolutePage = intPage
    For intRecord = 1 To myRS.PageSize

    Next
Else
Response.write("Nothing selected")
End If

Hth.

%>



"The one language all programmers understand is profanity."
 
Old July 31st, 2006, 04:18 PM
Authorized User
 
Join Date: May 2006
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for that. But I have the following and it conflicts:
Code:
If request.form("minAge") <> "" then 
    intAgemin = CInt(Request("minAge"))
    intAgemax = CInt(Request("maxAge"))
    mySQLmin = "SELECT * FROM tbl_brother WHERE BrAge BETWEEN " & intAgemin & " AND " & intAgemax & ";"
    myRS.Open mySQLmin, myCon,3,3,1
    myRS.AbsolutePage = intPage 
    For intRecord = 1 To myRS.PageSize

    Next Else
Response.write("Nothing selected")
End If

Select Case Request("Action")
    case "<<"
        intpage = 1
    case "<"
        intpage = CInt(Request("intpage"))-1
        if intpage < 1 then intpage = 1
    case ">"
        intpage = CInt(Request("intpage"))+1
        if intpage > intPageCount then intpage = IntPageCount
    Case ">>"
        intpage = intPageCount
    case else
        intpage = 1
end select
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>Testing</TITLE>
</HEAD>
<BODY>
<table border="1">
 <tr>
    <th width="15%" scope="col">STATUS</th>
    <th width="20%" scope="col">ORIGIN</th>
    <th width="20%" scope="col">NATIONALITY</th>
  </tr>
[b]<%
myRS.AbsolutePage = intPage 
For intRecord = 1 To myRS.PageSize %>
    <tr>
    <td><div align="center"><%= LCase(myRS("BrStatus"))%></td>
    <td><div align="center"><%= myRS("BrOrigin")%></td>
    <td><div align="center"><%= UCase(myRS("BrNational"))%></td>
  </tr></table>
<%
myRS.MoveNext
If myRS.EOF Then Exit For 

Next

myRS.Close
set myRS = Nothing
myCon.Close
set myCon = nothing
%>
 
Old July 31st, 2006, 04:45 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

So do this instead:

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>Testing</TITLE>
</HEAD>
<BODY>
<table border="1">
 <tr>
    <th width="15%" scope="col">STATUS</th>
    <th width="20%" scope="col">ORIGIN</th>
    <th width="20%" scope="col">NATIONALITY</th>
  </tr>
If request.form("minAge") <> "" then
    intAgemin = CInt(Request("minAge"))
    intAgemax = CInt(Request("maxAge"))
    mySQLmin = "SELECT * FROM tbl_brother WHERE BrAge BETWEEN " & intAgemin & " AND " & intAgemax & ";"
    myRS.Open mySQLmin, myCon,3,3,1
    myRS.AbsolutePage = intPage
    For intRecord = 1 To myRS.PageSize
%>
   <tr>
    <td><div align="center"><%= LCase(myRS("BrStatus"))%></td>
    <td><div align="center"><%= myRS("BrOrigin")%></td>
    <td><div align="center"><%= UCase(myRS("BrNational"))%></td>
  </tr></table>


<%
myRS.MoveNext
If myRS.EOF Then Exit For

Next

myRS.Close
set myRS = Nothing
myCon.Close
set myCon = nothing

Else
Response.write("Nothing selected")
End If

Select Case Request("Action")
    case "<<"
        intpage = 1
    case "<"
        intpage = CInt(Request("intpage"))-1
        if intpage < 1 then intpage = 1
    case ">"
        intpage = CInt(Request("intpage"))+1
        if intpage > intPageCount then intpage = IntPageCount
    Case ">>"
        intpage = intPageCount
    case else
        intpage = 1
end select
%>


"The one language all programmers understand is profanity."
 
Old August 1st, 2006, 03:53 PM
Authorized User
 
Join Date: May 2006
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks...but I now get this:

Error Type:
Microsoft VBScript compilation (0x800A040F)
Invalid 'exit' statement
/MiddlePath/try3.asp, line 40, column 22
If myRS.EOF Then Exit For
---------------------^








Similar Threads
Thread Thread Starter Forum Replies Last Post
Operation is not allowed when the object is closed lightmaker Classic ASP Basics 1 June 6th, 2008 12:29 PM
Operation is not allowed when the object is closed kingroon Classic ASP Databases 2 February 5th, 2008 10:29 AM
Object is closed. Why? myself Classic ASP Basics 2 July 10th, 2006 06:16 PM
Operation is not allowed when the object is closed kah Javascript How-To 2 February 16th, 2005 07:20 AM
operation is not allowed when object is closed shoakat Classic ASP Databases 1 November 26th, 2004 12:17 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.