ASP调用sqlserver2000存储过程能返回字符串吗?

亚细亚 2008-04-02 10:09:55
存储过程如:
create procedure material_info_exist_p
@P_materailName varchar(256),
@P_materialSpec varchar(128),
@p_materialUnit varchar (64),
@p_HelpCode varchar (32),
@materialID int output,
@materailName nvarchar(256) output,
@materialSpec nvarchar(128) output,
@test nvarchar (1000) output,
@materialUnit varchar (64) output

as
declare @sqlstr varchar(3000)
SET NOCOUNT ON
begin
if (select count(*) from material_info_t where materialName=@P_materailName and materialSpec=@P_materialSpec and isvalid=1)=0
begin
insert into material_info_t (MaterialName,HelpCode,MaterialSpec,MaterialUnit)values(@P_materailName,@p_HelpCode,@P_materialSpec,@p_materialUnit)
set @materialID=@@IDENTITY
set @test='select count(*) from material_info_t where materialName='+@P_materailName+' and materialSpec='+@P_materialSpec+' and isvalid=1'
end
else
begin
select @materialID=materialid,@materailName=materialName,@materialSpec=materialSpec,@materialUnit=materialUnit
from material_info_t where isvalid=0 and
materialName=@P_materailName and materialSpec=@P_materialSpec and materialUnit=@p_materialUnit and HelpCode=@p_HelpCode
end
end
asp调用存储过程:
set cmd=server.createobject("adodb.command")
cmd.activeconnection=conn
adCmdSPStoredProc = 4
adParamReturnValue = 4
adParaminput = 1
adParamOutput = 2
adInteger = 3
adVarChar = 200
adVarWChar = 202
'======================
cmd.commandtype = adcmdstoredproc
cmd.commandtext = "material_info_exist_p"
cmd.Parameters.Refresh
cmd.CommandType =adCmdSPStoredProc
cmd.Prepared = true

cmd.parameters.append cmd.createparameter("@P_materailName",adVarChar,adParaminput,128,materialname)
cmd.parameters.append cmd.createparameter("@p_HelpCode",adVarChar,adParaminput,128,HelpCode)
cmd.parameters.append cmd.createparameter("@P_materialSpec",adVarChar,adParaminput,128,materialSpec)
cmd.parameters.append cmd.createparameter("@p_materialUnit",adVarChar,adParaminput,8,materialunit)
'
cmd.parameters.append cmd.createparameter("@materialID",adInteger,adParamOutput)
cmd.parameters.append cmd.createparameter("@materailName",adVarChar,adParamOutput,256)
cmd.parameters.append cmd.createparameter("@materialSpec",adVarChar,adParamOutput,128)
cmd.parameters.append cmd.createparameter("@materialUnit",adVarChar,adParamOutput,64)

cmd.parameters.append cmd.createparameter("@test",adVarChar,adParamOutput,256)

cmd.execute()
test1 = cmd.Parameters("@test").value
response.Write("test1="&test1&"<br>")

为什么response.Write("test1="&test1&"<br>")中test1变量得不到存储过程中的字符串?
...全文
128 点赞 收藏 7
写回复
7 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
亚细亚 2008-04-02
[Quote=引用 6 楼 songpengasp 的回复:]
返回字符串 再转成 整数好了

还有一种办法 就是按照数据集方式返回
[/Quote]
具体怎么该,谢谢!
回复
No_Data_Found 2008-04-02
返回字符串 再转成 整数好了

还有一种办法 就是按照数据集方式返回
回复
亚细亚 2008-04-02
好像只能输出一个参数.要么是@materialID,要么是@test,难道不能同时输出吗?
回复
亚细亚 2008-04-02
如果返回一个字符串可以,但是要同时返回一个整数和一个字符串的话,好像只能返回字符串,不能返回整数.
回复
hookee 2008-04-02
cmd.commandtype = adcmdstoredproc
cmd.commandtext = "material_info_exist_p"
cmd.CommandType =adCmdSPStoredProc
cmd.parameters.append cmd.createparameter("@P_materailName",adVarChar,adParaminput,128,materialname)
cmd.parameters.append cmd.createparameter("@P_materialSpec",adVarChar,adParaminput,128,materialSpec)
cmd.parameters.append cmd.createparameter("@p_materialUnit",adVarChar,adParaminput,8,materialunit)
cmd.parameters.append cmd.createparameter("@p_HelpCode",adVarChar,adParaminput,128,HelpCode)
cmd.parameters.append cmd.createparameter("@materialID",adInteger,adParamOutput)
cmd.parameters.append cmd.createparameter("@materailName",adVarChar,adParamOutput,256)
cmd.parameters.append cmd.createparameter("@materialSpec",adVarChar,adParamOutput,128)
cmd.parameters.append cmd.createparameter("@test",adVarChar,adParamOutput,256)
cmd.parameters.append cmd.createparameter("@materialUnit",adVarChar,adParamOutput,64)
cmd.execute()
test1 = cmd.Parameters(7).value
response.Write("test1="&test1&" <br>")
试试看
回复
No_Data_Found 2008-04-02
相关推荐
发帖
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2008-04-02 10:09
社区公告
暂无公告