本文介绍了“对象关闭时不允许操作"执行存储过程时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的存储过程,当我从我的经典 ASP 代码中调用它时,我收到了错误:
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 closed.
当我尝试进行记录计数时.
when I try to do a record count.
有人知道这里出了什么问题吗?
Does anyone know what is wrong here?
我正在尝试返回表格 @t
.
I am trying to return the table @t
.
谢谢.
USE [Hires_new]
GO
/****** Object: StoredProcedure [dbo].[sp_selectNewHireWorkPeriodsSQL] Script Date: 05/13/2013 14:04:12 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:
-- Create date:
-- Description:
-- =============================================
ALTER PROCEDURE [dbo].[sp_selectNewHireWorkPeriodsSQL]
-- Add the parameters for the stored procedure here
AS
declare @t table (HireID int, StartDate datetime, EndDate datetime, date_initiated datetime, date_closed datetime, firmName nvarchar(100), InquiryID int)
DECLARE @acc INT
SET @acc = 1
DECLARE @max INT
select @max = max(HireID) from NewHire
WHILE (@acc <= @max)
BEGIN
IF (@acc in (select HireID from NewHire))
BEGIN
insert into @t
select HireID, StartDate, EndDate, date_initiated, date_closed, firmName, Inquiries.InquiryID
from WorkPeriod, Firms, Inquiries
where HireID = @acc and WorkPeriod.FirmID = Firms.FirmID and WorkPeriod.InquiryID = Inquiries.InquiryID
order by HireID,StartDate DESC
END
set @acc = @acc + 1
END
select * from @t
Asp经典代码
selectNewHireWorkPeriodsSQL = "EXEC sp_selectNewHireWorkPeriodsSQL"
Set rsNewHireWorkPeriods = Server.CreateObject("ADODB.Recordset")
rsNewHireWorkPeriods.Open selectNewHireWorkPeriodsSQL,ConnectionString,adOpenStatic
NumOfNewHireWorkPeriods = rsNewHireWorkPeriods.RecordCount
response.write(NumOfNewHireWorkPeriods)
推荐答案
在你的存储过程中试试这个:
Try this in your stored procedure:
SET NOCOUNT ON
SET ANSI_WARNINGS OFF
AS
的正下方.
这篇关于“对象关闭时不允许操作"执行存储过程时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!