 |
| 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
|
|
|
|

July 31st, 2006, 05:52 AM
|
|
Authorized User
|
|
Join Date: May 2006
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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 :)
|
|

July 31st, 2006, 08:37 AM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
You dont have a connection open between your app and the database.
"The one language all programmers understand is profanity."
|
|

July 31st, 2006, 09:27 AM
|
|
Authorized User
|
|
Join Date: May 2006
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Dims & Connections are all above...:)
What other code should i show that may help?
|
|

July 31st, 2006, 12:41 PM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
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."
|
|

July 31st, 2006, 04:18 PM
|
|
Authorized User
|
|
Join Date: May 2006
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
%>
|
|

July 31st, 2006, 04:45 PM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
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."
|
|

August 1st, 2006, 03:53 PM
|
|
Authorized User
|
|
Join Date: May 2006
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
---------------------^
|
|
 |