ASP调用存储过程问题
无漾 2017-08-10 05:20:36 批量将rs记录集里的数据导入到MSSQL中,使用了存储过程,但是ASP循环调用存储过程和赋值不对,另外参数SHU怎么赋值??
MSSQL存储过程:
USE [ceshi]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[InsertTest]
@A varchar(50),
@B varchar(50),
@shu int
as
begin
declare @i int
set @i=1
while @i<=@shu
begin
insert into test (A,B) VALUES (@A,@B)
SET @i=@i+1
end
end
——————
ASP调用,赋值:
<!--#include file="conn.asp"-->
<!--#include file="adovbs.inc"-->
<%
DIM U,P,MyComm
SHU=0
do while not rs.eof
SHU=SHU+1
Set MyComm = Server.CreateObject("ADODB.Command")
MyComm.ActiveConnection = conn
MyComm.CommandText = "InsertTest"
MyComm.CommandType = 4
MyComm.Prepared = true
MyComm.Parameters.append MyComm.CreateParameter("@A", 200, 1, 20,RS("U"))
MyComm.Parameters.append MyComm.CreateParameter("@B",200,1,50,RS("P"))
MyComm.Parameters.append MyComm.CreateParameter("@SHU",200,1,-1,SHU)
MyComm.Execute
rs.movenext
loop
Set MyComm = Nothing
%>