首页 新闻 会员 周边

pb9为什么不能调用带有返回值的存储过程?

0
悬赏园豆:20 [已关闭问题] 关闭于 2012-03-24 15:50

使用的表
CREATE TABLE [dbo].[user](
 [id] [int] IDENTITY(1,1) NOT NULL,
 [user_reg] [varchar](10) NOT NULL,
 [password] [nchar](10) NULL,
 CONSTRAINT [PK_user] PRIMARY KEY CLUSTERED
(
 [id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

已经存在数据:
id user_reg password
2 America         456      

建存储过程:
create procedure deal_user @p_flag int output
as
--INSERT INTO [test].[dbo].[user]([user_reg],[password])VALUES('lk' ,'123')
--select [user_reg],[password] from [test].[dbo].[user] where [user_reg] = 'lk'
set @p_flag = 1
--return 12

调用存储过程:
declare @out int
exec deal_user @out output
select @out
显示结果:
1

pb调用存储过程:
int pf,pr
pf=3

SQLCA.DBMS = "MSS Microsoft SQL Server"
SQLCA.Database = "szjdw"
SQLCA.LogPass = "850414"
SQLCA.ServerName = "WQ1DRLUSHNBAPXH"
SQLCA.LogId = "sa"
SQLCA.AutoCommit = False
SQLCA.DBParm = ""

Connect using SQLCA;
If SQLCA.SQLCode <> 0 Then
       MessageBox ("提示","数据库联接出错"+SQLCA.SQLErrText )
End If

DECLARE ut PROCEDURE FOR deal_user  @p_flag=:pf OUTPUT;

EXECUTE ut;
commit using SQLCA;
fetch ut into :pr;
close ut;
if sqlca.sqlcode<>0 then
 messagebox("NO",sqlca.sqlerrtext)
else
 messagebox("pf","执行结果是:"+string(sqlca.sqlcode)+"~r~n"+string(pr))
end if


结果显示:
---------------------------
NO
---------------------------
Procedure has not been executed or has no results
---------------------------
确定  
---------------------------

问题:
为什么不能成功调用存储过程啊?

szjdw的主页 szjdw | 初学一级 | 园豆:6
提问于:2011-10-19 20:29
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册