473,385 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Operation is not allowed when the object is closed.

hi i am trying to use the record count object to count the number of
books in a database of mine. i get this error saying that i have closed
the object and i dont think i closed it. here is my code

<% dim strBrowse, strSearch, Count
Count = objRS.RecordCount

strBrowse = request.querystring("strBrowse")
strSearch = request.querystring("strSearch")

if strBrowse > "" then
strSQL = "SELECT distinctrow tblCategories.strCategory,
tblBookDescription.ISBN, tblBookDescription.strTitle,
tblBookDescription.strDescription " & _
"FROM tblBookDescription INNER JOIN tblCategories ON
tblBookDescription.ISBN = tblCategories.ISBN " & _
"Where (((tblCategories.strCategory) = '" & strBrowse &
"')) " & _
"ORDER BY tblBookDescription.strTitle "

End If
if strSearch > "" then
strSQL= "SELECT distinctrow tblBookDescription.strTitle,
tblBookDescription.strDescription, tblBookDescription.ISBN " & _
"FROM tblAuthors INNER JOIN (tblBookDescription INNER JOIN
tblAuthorsBooks ON tblBookDescription.ISBN = tblAuthorsBooks.ISBN) ON
tblAuthors.AuthorID = tblAuthorsBooks.AuthorID "&_
"WHERE ((tblAuthors.strLastName Like '%"&strSearch&"%') "& _
"OR (tblAuthors.strFirstName Like '%"&strSearch&"%') "&_
"OR (tblBookDescription.strTitle Like '%"&strSearch&"%') "&_
"OR (tblBookDescription.strDescription Like '% "&strSearch&"
%') "& _
"OR (tblBookDescription.strPublisher Like '%"&strSearch&"%'))
"&_
"ORDER BY tblBookDescription.strTitle;"
end if

'response.write("strSQL = " & strSQL)

Set objRS = Server.CreateObject("ADODB.Recordset")
-----------------------------------------------------------------------------error
here
objRS.open strSQL, objConn, 1, objRS.RecordCount

%>
</td>
<td valign="top"><font face="Comic Sans MS" color="blue">
<%
if strBrowse > "" and Count = 1 then
response.write("We Carry " & Count & " " & strBrowse & "
book.")
else if strBrowse > "" and Count > 1 then
response.write("We Carry " & Count & " " & strBrowse & "
books.")
end if
end if

if strSearch > "" and Count = 1 then
response.write("Search results: " & Count & " book matches '"
& strSearch & "'.")
else if strSearch > "" and Count > 1 then
response.write("Search results: " & Count & " books match '" &
strSearch & "'.")
end if
end if
%>
thanks for the help

Feb 23 '06 #1
1 3376
I believe the last parameter to Open should be a 3 for a dynamic recordset.

objRS.open strSQL, objConn, 1, 3

next, this line of code :

Count = objRS.RecordCount

is being called before the recordset is open, thus the RS is not OPEN yet...

D.
isaac2004 wrote:
hi i am trying to use the record count object to count the number of
books in a database of mine. i get this error saying that i have closed
the object and i dont think i closed it. here is my code

<% dim strBrowse, strSearch, Count


strBrowse = request.querystring("strBrowse")
strSearch = request.querystring("strSearch")

if strBrowse > "" then
strSQL = "SELECT distinctrow tblCategories.strCategory,
tblBookDescription.ISBN, tblBookDescription.strTitle,
tblBookDescription.strDescription " & _
"FROM tblBookDescription INNER JOIN tblCategories ON
tblBookDescription.ISBN = tblCategories.ISBN " & _
"Where (((tblCategories.strCategory) = '" & strBrowse &
"')) " & _
"ORDER BY tblBookDescription.strTitle "

End If
if strSearch > "" then
strSQL= "SELECT distinctrow tblBookDescription.strTitle,
tblBookDescription.strDescription, tblBookDescription.ISBN " & _
"FROM tblAuthors INNER JOIN (tblBookDescription INNER JOIN
tblAuthorsBooks ON tblBookDescription.ISBN = tblAuthorsBooks.ISBN) ON
tblAuthors.AuthorID = tblAuthorsBooks.AuthorID "&_
"WHERE ((tblAuthors.strLastName Like '%"&strSearch&"%') "& _
"OR (tblAuthors.strFirstName Like '%"&strSearch&"%') "&_
"OR (tblBookDescription.strTitle Like '%"&strSearch&"%') "&_
"OR (tblBookDescription.strDescription Like '% "&strSearch&"
%') "& _
"OR (tblBookDescription.strPublisher Like '%"&strSearch&"%'))
"&_
"ORDER BY tblBookDescription.strTitle;"
end if

'response.write("strSQL = " & strSQL)

Set objRS = Server.CreateObject("ADODB.Recordset")
-----------------------------------------------------------------------------error
here
objRS.open strSQL, objConn, 1, objRS.RecordCount

%>
</td>
<td valign="top"><font face="Comic Sans MS" color="blue">
<%
if strBrowse > "" and Count = 1 then
response.write("We Carry " & Count & " " & strBrowse & "
book.")
else if strBrowse > "" and Count > 1 then
response.write("We Carry " & Count & " " & strBrowse & "
books.")
end if
end if

if strSearch > "" and Count = 1 then
response.write("Search results: " & Count & " book matches '"
& strSearch & "'.")
else if strSearch > "" and Count > 1 then
response.write("Search results: " & Count & " books match '" &
strSearch & "'.")
end if
end if
%>
thanks for the help

Feb 23 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Matthew Louden | last post by:
The following ASP code yields the following error, but actually the new record is stored in database. The same error happens when the application deletes a record, such as sqlStmt ="delete from...
1
by: cliverama | last post by:
help! fried brains.... asp calling a sqlserver7 stored proc which dynamically builds a sqlstatement & passes it to sp_executesql asp page gives the operation not allowed when object is closed...
17
by: James Baker | last post by:
I'm getting an error: "Operation is not allowed when the object is closed." on the lines of code below. I can't imagine why the object would be closed where it says it will be, I've just opened it...
1
by: | last post by:
So, I am getting this really annoying error.. the SQL Statement executes perfectly in Query Analyzer.. all I am doing is basically duplicating a row (insert into select from) from one table back...
2
by: Arpan | last post by:
An ASP application updates a SQL Server database table after a Form is submitted after which the user is directed to another page that should display the updated records. If the code is ...
1
by: amitbadgi | last post by:
Hello guys I am getting this error while converting an asp applicayion to asp.net Exception Details: System.Runtime.InteropServices.COMException: Operation is not allowed when the object is...
8
by: Jim in Arizona | last post by:
I've been using an example out of a book to be able to edit the rows in a database. I am getting the following error: ========================================================...
1
by: Matt | last post by:
Got this problem that killing me...what am i doing wrong with this old dll. When i call the function from asp i get "Operation is not allowed when object is closed" any clue will be...
5
by: Sonasang | last post by:
Hi , I am creating a web page with ASP and Javascript.We have shared the foldres containg the code and all our team members are accessing the code. There is no problem for me when i run the...
1
by: Ryan Liu | last post by:
Hi, I have a 100 clients/ one server application, use ugly one thread pre client approach. And both side user sync I/O. I frequently see the error on server side(client side code is same, but...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.