找回密码
 注册
搜索
热搜: 回贴
微赢网络技术论坛 门户 数据库 查看内容

用户登录存储过程

2009-12-14 18:26| 发布者: admin| 查看: 58| 评论: 0|原作者: 韩菱纱

☆CREATEPROCEDUREPrc_A......



CREATE PROCEDURE Prc_Ad_Login
@AdName varchar(32),
@AdPwd nchar(32),
@Count int output,
@Err varchar(64) output
AS
if exists(select intsuid from sysuser where varsuname=@AdName)
begin
declare @suid int
declare @dteErrs datetime
declare @npwd nchar(32)
declare @Lock bit
declare @intErr int
declare @Errpart int
declare @ErrCount int
select @suid=intsuid, @dteErrs=dteErr,@intErr=intErrCount,@npwd=narsupwd,@lock=bitLock from sysuser where varsuname=@Adname
select @ErrCount=intsuerrcount,@Errpart=intsuerrminute from sysbasic
if(@npwd=@Adpwd)
begin
if(@Lock=1)
begin
select @Count=2
select @Err='你的帐户已被锁定,请联系站长!'
end
else
begin

select @Count=0
end
end
else
begin
if(@Lock=0)
begin
if(datediff(n,@dteErrs,getdate())<@Errpart)
begin
if(@intErr<@ErrCount)
begin
update sysuser set intErrCount=intErrCount+1,dteErr=getdate() where intsuid=@suid
if(@intErr=(@ErrCount-1))
begin
select @Count=4
select @Err='登录错误过多,你的帐号被系统暂时锁定!'
end
else
begin
select @Count=1
select @Err='用户名或密码错误!'
end
end
else
begin
update sysuser set dteErr=getdate() where intsuid=@suid
select @Count=3
select @Err='你的帐号在一定时间内不允许登录!'
end
end
else
begin
update sysuser set dteErr=getdate(),intErrCount=1 where intsuid=@suid
select @Count=1
select @Err='用户名或密码错误!'
end
end
end
end
else
begin
select @Count=1
select @Err='用户名或密码错误!'
end
GO

最新评论

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-29 15:33 , Processed in 0.178812 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

返回顶部