Operation is not allowed when the object is closed

Discussion in 'ASP General' started by Mike P, Aug 7, 2008.

  1. Mike P

    Mike P Guest

    I keep getting this error whenever I try to run the following code (the
    connection string is global and declared at the top of the page) :

    <%
    Option Explicit
    Dim strConnection
    %>

    <!--#include file="include_connection.asp"-->

    dim andList
    dim rsSearch
    dim rsSQL

    set rsSearch = CreateObject("ADODB.Recordset")

    '==== select a LOAD ID subset it required
    andList = ""

    '==== select a companyname subset it required
    if (len(Request("name"))>0) then
    andList = andList & " AND c.[name] like '%" &
    replace(Request("name"),"'","''") & "%' " & vbcrlf
    end if

    '==== select a contactname subset it required
    if Request("contactName") > "" then
    andList = andList & " AND co.contactname like '%" &
    Request("contactname") & "%' " & vbcrlf
    end if

    if (andList <> "") then
    rsSQL = "exec GetEmailCompanyList @pUserKey = '"&lintUserKey&"' ,
    @pAndList = '"&replace(andList,"'","''")&"'"
    else
    rsSQL = "exec GetEmailCompanyList @pUserKey = '"&lintUserKey&"'"
    end if

    '==set page size and cursor position
    rsSearch.PageSize = 100
    rsSearch.CursorLocation = adUseClient

    rsSearch.Open rsSQL, strConnection

    'If rsSearch.State = adStateOpen then
    ' response.write rsSQL & " - Open"
    ' Response.end
    'else
    ' response.write rsSQL & " - Closed"
    ' Response.end
    'end if

    if (rsSearch.EOF) then
    Response.Write "<P align=center><font size=2 color=000000><B>No
    Companies Found"
    Response.end
    end if

    I get the error on the line 'if (rsSearch.EOF) then' and only when I
    pass a value for name or contactname.



    *** Sent via Developersdex http://www.developersdex.com ***
     
    Mike P, Aug 7, 2008
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    2,134
    Kevin Spencer
    Aug 10, 2005
  2. Matthew Louden
    Replies:
    6
    Views:
    261
    Ken Schaefer
    Sep 28, 2003
  3. cliverama
    Replies:
    1
    Views:
    142
    Aaron Bertrand [MVP]
    Nov 5, 2003
  4. Guest
    Replies:
    1
    Views:
    241
    Ray Costanzo [MVP]
    Dec 20, 2004
  5. TC
    Replies:
    1
    Views:
    150
    madhouse
    Jan 12, 2005
Loading...

Share This Page