“Operation is not allowed when the object is closed” when executing stored procedure

后端 未结 7 688
猫巷女王i
猫巷女王i 2020-12-20 11:12

This is my stored procedure, and when I am calling it from my classic ASP code, I am getting the error:

Operation is not allowed when the object is c

相关标签:
7条回答
  • 2020-12-20 11:24

    Warnings may confuse the result. SET ANSI_WARNINGS OFF avoids losing the SELECT result or output parameter values.

    0 讨论(0)
  • 2020-12-20 11:26

    I know that this is very old. But in my case, it was the order of parameters. It worked after I set the parameters as they appear in the stored procedure. I know that there is no logical explanation to this as parameters are named and the order should not matter really.

    0 讨论(0)
  • 2020-12-20 11:31

    If, for whatever reason the stored procedure does not return a result set, empty or otherwise, the recordset object will not be open, so:

    if rs.state = adStateOpen then x = rs.recordcount
    
    0 讨论(0)
  • 2020-12-20 11:42

    I am sure that this will not affect many people, but I just stumbled upon this issue. This was working in production and not in the development environment. What I found was that our stored procedure had a print statement in the development environment. I guess the print statement was mucking up the works and ADODB thought that was the record set.

    0 讨论(0)
  • 2020-12-20 11:45

    This can be caused by a print statement in your stored procedure. I accidently left a few in after some performance debugging....hopefully this helps someone still working in legacy ADO.

    0 讨论(0)
  • 2020-12-20 11:49

    Try this in your stored procedure:

    SET NOCOUNT ON
    SET ANSI_WARNINGS OFF
    

    Right below the AS.

    0 讨论(0)
提交回复
热议问题