用存储过程进行用户登陆认证

username = " admin "
password
= " admin888 "
set  comm = server.CreateObject( " adodb.command " )
comm.activeconnection
= " PROVIDER=SQLOLEDB;DATA SOURCE=127.0.0.1;UID=sa;PWD=;DATABASE=try "
' '以comm对象建立存储过程连接,4代表连接类型为存储过程 
comm.commandtext = " login " ' 存储过程名字
comm.commandtype = 4
' 以p1为名称建立comm对象的parameter方法。将第一个参数fullname追加到p1集合中 
     ' fullname 调用的第一个参数的名称 
     ' 200 参数类型 varchar型 
     ' 1 参数流向 输入,输入为1,输出为2 
     ' 50 参数的长度 50 
     ' request("fullname") 赋参数出始值 
set  p1 = comm.createparameter( " fullname " , 200 , 1 , 50 ,username)
comm.parameters.Append p1
' 以p1为名称建立comm对象的parameter方法。将第二个参数password追加到p1集合中 
'
具体同上 
set  p1 = comm.createparameter( " inpassword " , 200 , 1 , 50 ,password)
comm.parameters.Append p1
' 以p1为名称建立comm对象的parameter方法。将第三个参数check追加到p1集合中 
'
129 参数类型 char型 
'
2 参数流向 输出 
'
3 参数长度 3 
set  p1 = comm.createparameter( " check " , 129 , 2 , 3 )
comm.parameters.Append p1
comm.execute
if  comm( " check " ) = " yes "   then
response.Write 
" <script>alert('欢迎光临!');</script> "
else
response.Write 
" <script>alert('用户名或密码错误!');</script> "
end   if  
set  comm = nothing


' 存储过程:
Create PROCEDURE login
@infullname nvarchar(
50 ),
@inpassword nvarchar(
50 ),
@outcheck 
char ( 3 ) output
as
if  exists( select   *  from admin where username = @infullname  and  [password] = @inpassword)
select  @outcheck = " yes "
else
select  @outcheck = " no "
GO

转载于:https://www.cnblogs.com/breezeblew/archive/2008/05/01/1178438.html

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值