在ASP Classic中调用SQL Server存储过程时关闭对象时,不允许进行操作

时间:2016-01-29 18:54:34

标签: sql-server stored-procedures asp-classic

在我的asp经典代码中,我想调用存储过程。但是,如果我尝试,我会

Operation is not allowed when the object is closed. 

ASP代码:

dim soc
dim sql
dim dbConn
dim adRsTKIDEmpNum


set soc = Request.QueryString("id_list")


set dbConn = Server.CreateObject("ADODB.Connection")
set adRsTKIDEmpNum = Server.CreateObject("ADODB.Recordset")

dbConn.Open Application("System_ConnectionString")



sql = "sp_getEmployeeDetail '2411, 3468'"
adRsTKIDEmpNum.Open sql, dbConn, 1

do while not adRsTKIDEmpNum.EOF


loop

Response.write sql

当我致电do while not adRsTKIDEmpNum.EOF时,我收到错误。

存储过程

Alter Procedure dbo.sp_getEmployeeDetail
    @IDList varchar (max)
As

Declare @EmployeeDetail table(ID int,Employee_Number int)

insert into @EmployeeDetail(ID, Employee_Number) 
select A.Item, B.employee_number from people.dbo.udf_Split(@IDList, ',') A
left join people.dbo.employee B on A.Item=B.ID

select * from @EmployeeDetail

GO

有谁知道什么是错的?

由于

1 个答案:

答案 0 :(得分:0)

Alter Procedure dbo.sp_getEmployeeDetail
    @IDList varchar (max)
As
SET NOCOUNT ON
Declare @EmployeeDetail table(ID int,Employee_Number int)

insert into @EmployeeDetail(ID, Employee_Number) 
select A.Item, B.employee_number from people.dbo.udf_Split(@IDList, ',') A
left join people.dbo.employee B on A.Item=B.ID

select * from @EmployeeDetail

GO