sp_executesql Operation is not allowed when the object is closed

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default sp_executesql Operation is not allowed when the object is closed

    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 error
    this is the asp code:

    Set connInc= server.CreateObject("ADODB.Connection")
    connInc.Open "DSN=db_database;User ID=userid;Password=xxxxxx"
    Set rsInc= server.CreateObject("ADODB.Recordset")
    strSQL = "usp_incmpwfilter_rs 'M9S','2','1','A,B'" '-these are
    string variables passed dependant on asp form selections.
    rsInc.Open strSQL, connInc
    if not rsInc.eof then ^falls over here

    usp_incmpfilter_rs builds a dynamic sql statement which works in query
    analyser and passes it to sp_executesql:

    CREATE PROCEDURE usp_incmpwfilter_rs
    (
    @strPeriodID varchar ,
    @intLevelDetailID varchar,
    @intLevelReportID varchar,
    @strFilters varchar
    )
    AS

    set nocount on

    declare @strSQL nvarchar

    set @strSQL = " SELECT rather complex dynamically built but working in
    query analyser SQL statement containing @params goes here: can post if
    requested"

    execute sp_executesql @strSQL

    what am i missing? i have had right nitemare getting this far!!!! any
    help much appreciated..
    cliverama Guest

  2. Similar Questions and Discussions

    1. #39141 [NEW]: Only one prepared statement allowed per pdo object
      From: aspen dot olmsted at alliance dot biz Operating system: Windows XP SP2 PHP version: 5CVS-2006-10-12 (snap) PHP Bug Type: ...
    2. Operation is not allowed when the object is closed
      When I first open my ASP page, I get the error "Operation is not allowed when the object is closed" for a page containing a result set from a...
    3. Operation is not valid due to the current state of the object
      I'm using the Oracle .NET data provider in my ASP.NET application to connect to Oracle. I am recieveing the error: ...
    4. Operation is not allowed when the object is closed.
      i have this stored procedure... CREATE PROCEDURE p_sale_tax @locid INTEGER, @sdate VARCHAR(10), @edate VARCHAR(10) AS SET NOCOUNT ON SET @sdate...
    5. Error "Operation is not allowed when the object is closed"
      The following ASP code yields the following error, but actually the new record is stored in database. The same error happens when the application...
  3. #2

    Default Re: sp_executesql Operation is not allowed when the object is closed

    > Set connInc= server.CreateObject("ADODB.Connection")
    > connInc.Open "DSN=db_database;User ID=userid;Password=xxxxxx"
    > Set rsInc= server.CreateObject("ADODB.Recordset")
    > strSQL = "usp_incmpwfilter_rs 'M9S','2','1','A,B'" '-these are
    > string variables passed dependant on asp form selections.
    > rsInc.Open strSQL, connInc
    > if not rsInc.eof then ^falls over here
    You might have better luck trapping EOF by using the connection object
    instead of an explicit ADODB.Recordset.

    Set connInc = CreateObject("ADODB.Connection")
    connInc.Open "DSN=db_database;User ID=userid;Password=xxxxxx"
    ' consider dropping the DSN! See [url]www.aspfaq.com/2126[/url]
    strSQL = "usp_incmpwfilter_rs 'M9S','2','1','A,B'"
    set rsInc = connInc.execute(strSQL)
    if not rsInc.EOF then
    response.write "there are rows"
    else
    response.write "there are no rows"
    end if
    > set @strSQL = " SELECT rather complex dynamically built but working in
    > query analyser SQL statement containing @params goes here: can post if
    > requested"
    As complex is it might be, we're generally pretty smart people, and can
    figure it out. Also, could you

    PRINT @strSQL

    And show us that? (The result, I would think, is far more important than
    the method.) It might be that your SQL is malformed, etc.

    Also, does this return 1 resultset, 5 resultsets, is it ever possible that
    it could be EOF?

    microsoft.public.inetserver.asp.general dropped from followups.


    Aaron Bertrand [MVP] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139