[分享] 用户登录存储过程

[复制链接]

该用户从未签到

108

主题

209

回帖

6045

积分

Intohard Team

Rank: 7Rank: 7Rank: 7

积分
6045
发表于 2007-7-5 10:24:11 | 显示全部楼层 |阅读模式
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=&#39;登录错误过多,你的帐号被系统暂时锁定!&#39;
   end
   else
   begin
   select @Count=1
   select @Err=&#39;用户名或密码错误!&#39;
   end
  end
  else
  begin
   update sysuser set dteErr=getdate() where intsuid=@suid
   select @Count=3
   select @Err=&#39;你的帐号在一定时间内不允许登录!&#39;
  end
  end
  else
  begin
  update sysuser set dteErr=getdate(),intErrCount=1 where intsuid=@suid
  select @Count=1
  select @Err=&#39;用户名或密码错误!&#39;
  end
end
end
end
else
begin
select @Count=1
select @Err=&#39;用户名或密码错误!&#39;
end
GO

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表