执行有返回值存储过程,返回的类型不是一个表(也就不是DataSet),是一个字条串如下:
存储过程如下:
CREATE PROC Login
@userName varchar(20),
@password varchar(20)
AS
IF NOT EXISTS(SELECT * FROM SysUser WHERE UserName = @userName)
RETURN -1
IF NOT EXISTS(SELECT * FROM SysUser WHERE UserName = @userName AND PWD = @password)
RETURN 1
RETURN 0
GO
请问代码怎么写啦!
------解决方案--------------------------------------------------------
执行效率好低的。
declare varchar(20) @oldpassword
select @oldpassword=PWD WHERE UserName = @userName
if @@Rowscount=0 return -1
if @oldpassword<>@password return 1
return 0
------解决方案--------------------------------------------------------
CREATE PROC Login
@userName varchar(20),
@password varchar(20),
@returnvalue int output
AS
IF NOT EXISTS(SELECT * FROM SysUser WHERE UserName = @userName)
set @returnvalue=-1
else IF NOT EXISTS(SELECT * FROM SysUser WHERE UserName = @userName AND PWD = @password)
set @returnvalue=1
else
set @returnvalue=0
GO