用sa通过查询分析器建立了个存储过程,在查询分析器中执行正常。
可是在PB中调用时报错:未能找到存储过程。
问题出在哪里呢?我查了一天了,资料也看了好多,可是没能解决。
求助!
源码:
存储过程
CREATE PROCEDURE up_CheckRight (
@as_UserCode varchar(20), --工号
@as_Pwd varchar(20), --密码
@ai_Right int, --权限
)
WITH ENCRYPTION
as
begin
set nocount on
declare @errno int
declare @errmsg varchar(255)
declare @sql varchar(5000)
--如果密码为空,则不验证密码
if @as_Pwd <> '' or @as_Pwd is not null
begin
if exists(select ID
From Employee
where [email protected]_UserCode
and [email protected]_Right)
return 1
end
return 0
set nocount off
error:
raiserror @errno @errmsg
-- rollback transaction
set nocount off
end
PB代码:
sqlca.autocommit=true
declare CheckRight Procedure for up_CheckRight
@as_UserCode =:ls_ucode,
@as_Pwd=:ls_pwd,
@ai_Right1=1073741824
execute CheckRight; //执行存储过程
CHOOSE CASE SQLCA.sqlcode
CASE 0
MessageBox("错误","用户名或密码错误,请重新输入!")
sle_ucode.text = ""
sle_ucode.SetFocus()
CASE 1
//登录登记
//登录成功后应在系统中记录日志
open(w_seat)
close(w_login)
CASE -1
MessageBox ("错误", "SQL错误代码:" + string (SQLCA.sqldbcode) + "~r~n" + SQLCA.sqlerrtext)
CASE 100
MessageBox ("End of Result Set", " rows fetched_wyy")
END CHOOSE
close CheckRight;
------解决方案--------------------
CREATE PROCEDURE dbo.up_CheckRight (
@as_UserCode varchar(20), --工号
@as_Pwd varchar(20), --密码
@ai_Right int, --权限
)
WITH ENCRYPTION
as
begin
set nocount on
declare @errno int
declare @errmsg varchar(255)
declare @sql varchar(5000)
--如果密码为空,则不验证密码
if @as_Pwd <> '' or @as_Pwd is not null
begin
if exists(select ID
From Employee
where [email protected]_UserCode
and [email protected]_Right)
return 1
end
return 0
set nocount off
error:
raiserror @errno @errmsg
-- rollback transaction
set nocount off