![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
create proc sp_UserAuthen
@name nvarchar(50),
@password nvarchar(50)
as
declare @n nvarchar(50);
declare @p nvarchar(50);
select @n=[Name],@p=[Password] from tbUser where [Name]=@name
if(@n is null)
return 1 /*user not exists*/
else if(@p<>@password)
return 2 /*password is wrong*/
else return 3 /*correct*/
create proc sp_UserAuthen
@name nvarchar(50),
@password nvarchar(50)
as
declare @n nvarchar(50);
declare @p nvarchar(50);
select @n=[Name],@p=[Password] from tbUser where [Name]=@name
if(isnull(@n,'1')='1')
return 1 /*user not exists*/
else if(@p<>@password)
return 2 /*password is wrong*/
else return 3 /*correct*/
些存储过程验证用户和密码是否正确。
返回值为 :1,2,3.
1:用户名不存在
2:密码不正确
3:正确