求助:asp+Sql Server 存储过程

此段是SqlServer存储过程:CREATEprocedure[dbo].[News_ADD](@News_Titlevarchar(50),@News_IDvarch... 此段是Sql Server 存储过程:

CREATE procedure [dbo].[News_ADD]
(@News_Title varchar(50),
@News_ID varchar(21) output)
as
set nocount on
begin
if not exists(select News_Title from table1 where News_Title = @News_Title)
begin
declare @RND varchar(6)
while exists(select News_ID from table1 where News_ID = @News_ID) or @News_ID = '' or @News_ID is null
begin
set @News_ID = replace(replace(replace(CONVERT(varchar, getdate(), 120 ),'-',''),' ',''),':','')
while @RND is null or @RND = '' or len(@RND) < 6
begin
set @RND = cast(cast(rand() * 1000000 as int) as varchar(6))
end
set @News_ID = @News_ID + '-' + @RND
end
insert into table1 values(@News_ID,@News_Title)
return 1
end
else
begin
return 0
end
end

该存储过程在SQL Server Management Studio 中测试正常,可以获得返回值 "return" 和 "@News_ID"

以下是ASP调用代码:

dim cmd,News_Title
News_Title = request.Form("News_Title")
set cmd = server.CreateObject("ADODB.Command")
with cmd
.ActiveConnection = conn
.commandtext = "News_sel"
.commandtype = 4
.prepared = true

.parameters.append .createparameter("@News_ID",200,2,21)
.parameters.append .createparameter("@News_Title",200,1,50,News_Title)
.execute
end with

response.Write(cmd.parameter(0))
set cmd = nothing

该段asp代码无法获取返回值 "return" 和 "@News_ID"
展开
 我来答
qijian1030
2010-01-09
知道答主
回答量:23
采纳率:0%
帮助的人:6.3万
展开全部
.parameters.append .createparameter("@News_ID",200,2,21)
.parameters.append .createparameter("@News_Title",200,1,50,News_Title)
改为.parameters.item("@News_Title").value = News_Title
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式