Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP General (http://www.velocityreviews.com/forums/f65-asp-general.html)
-   -   Operation is not allowed when the object is closed. (http://www.velocityreviews.com/forums/t800726-operation-is-not-allowed-when-the-object-is-closed.html)

isaac2004 02-22-2006 11:53 PM

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


dNagel 02-23-2006 12:27 AM

Re: Operation is not allowed when the object is closed.
 
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
>



All times are GMT. The time now is 01:28 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.