Operation is not allowed when the object is closed.

I

isaac2004

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
 
D

dNagel

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top