asp 存貯過(guò)程 (SQL版asp調(diào)用存儲(chǔ)過(guò)程)
更新時(shí)間:2007年11月22日 22:58:32 作者:
存貯過(guò)程(SQL樣版)
今天發(fā)個(gè)SQL存貯過(guò)程給大家認(rèn)識(shí)
CREATE PROCEDURE login_verify
(
@community_id int, --拿值
@username varchar(20),
@password varchar(40),
@result tinyint output
)
AS
set nocount ON
declare @service_deadline_date smalldatetime,@community_setting_max_online_count int ---定義一個(gè)變量為 短日期格式
select @community_setting_max_online_count=community_setting_max_online_count,@service_deadline_date=service_deadline_date from community_info where community_id=@community_id --這里是求最大登錄人數(shù)
if datediff(d,@service_deadline_date,getdate())>10 --其實(shí)這個(gè)是限制用戶(hù)的使用期,求當(dāng)前日期與庫(kù)中的記錄日期如時(shí)大于10天,則返回@result =11
begin
set @result=11 --超過(guò)使用期
return
end
if (select count(*) from online_user where =@community_setting_max_online_count">community_id=@community_id)>=@community_setting_max_online_count --根據(jù)庫(kù)中的記錄設(shè)定與當(dāng)前人數(shù)比較
begin
set @result=10 --超出在線(xiàn)人數(shù)限制 --返回@result=10
return
end
declare @stamia int,@last_update_stamia_date smalldatetime,@level_id int --定義變量 整型 短日期型 整型
declare @userid int ,@user_role int
select @userid=userid,@user_role=user_role,@stamia=stamia,@last_update_stamia_date=last_update_stamia_date,@level_id=level_id from user_info where username=@username and password=@password and community_id=@community_id and user_type=0
--從用戶(hù)信息表中,將一些信息寫(xiě)入到定義的三個(gè)變量中
if @userid is not null ----如果@userid 不變null值
begin --用戶(hù)名和密碼校驗(yàn)成功
set @result=1 --檢驗(yàn)成功
return
end
else
begin
set @result=0 ---登錄失敗
end
set nocount OFF
GO
我們給上面的過(guò)程取個(gè)名login_verify叫做
寫(xiě)成是ASP代碼中調(diào)用安全認(rèn)證的地方
'''事先已經(jīng)定義好conn
Set cmd.ActiveConnection=conn
cmd.CommandText="login_verify"
cmd.CommandType=&H0004
@community_id int, --拿值
@username varchar(20),
@password varchar(40),
@result int
cmd.Parameters.Append cmd.CreateParameter("@community_id",3)
cmd.Parameters.Append cmd.CreateParameter("@username ",200)
cmd.Parameters.Append cmd.CreateParameter("@password",200)
cmd("@community_id")=session("community_id")
cmd("@username")=request("userid")
cmd("@password")=request("userid")
cmd.execute
dim result
result=cmd("@result")
conn.close
if trim(result)="1" then
'''''''''''''登錄成功的提示與操作
else
''''''''''''''''''''''登錄失敗的提示與操作
end if
今天發(fā)個(gè)SQL存貯過(guò)程給大家認(rèn)識(shí)
復(fù)制代碼 代碼如下:
CREATE PROCEDURE login_verify
(
@community_id int, --拿值
@username varchar(20),
@password varchar(40),
@result tinyint output
)
AS
set nocount ON
declare @service_deadline_date smalldatetime,@community_setting_max_online_count int ---定義一個(gè)變量為 短日期格式
select @community_setting_max_online_count=community_setting_max_online_count,@service_deadline_date=service_deadline_date from community_info where community_id=@community_id --這里是求最大登錄人數(shù)
if datediff(d,@service_deadline_date,getdate())>10 --其實(shí)這個(gè)是限制用戶(hù)的使用期,求當(dāng)前日期與庫(kù)中的記錄日期如時(shí)大于10天,則返回@result =11
begin
set @result=11 --超過(guò)使用期
return
end
if (select count(*) from online_user where =@community_setting_max_online_count">community_id=@community_id)>=@community_setting_max_online_count --根據(jù)庫(kù)中的記錄設(shè)定與當(dāng)前人數(shù)比較
begin
set @result=10 --超出在線(xiàn)人數(shù)限制 --返回@result=10
return
end
declare @stamia int,@last_update_stamia_date smalldatetime,@level_id int --定義變量 整型 短日期型 整型
declare @userid int ,@user_role int
select @userid=userid,@user_role=user_role,@stamia=stamia,@last_update_stamia_date=last_update_stamia_date,@level_id=level_id from user_info where username=@username and password=@password and community_id=@community_id and user_type=0
--從用戶(hù)信息表中,將一些信息寫(xiě)入到定義的三個(gè)變量中
if @userid is not null ----如果@userid 不變null值
begin --用戶(hù)名和密碼校驗(yàn)成功
set @result=1 --檢驗(yàn)成功
return
end
else
begin
set @result=0 ---登錄失敗
end
set nocount OFF
GO
我們給上面的過(guò)程取個(gè)名login_verify叫做
寫(xiě)成是ASP代碼中調(diào)用安全認(rèn)證的地方
'''事先已經(jīng)定義好conn
Set cmd.ActiveConnection=conn
cmd.CommandText="login_verify"
cmd.CommandType=&H0004
@community_id int, --拿值
@username varchar(20),
@password varchar(40),
@result int
cmd.Parameters.Append cmd.CreateParameter("@community_id",3)
cmd.Parameters.Append cmd.CreateParameter("@username ",200)
cmd.Parameters.Append cmd.CreateParameter("@password",200)
cmd("@community_id")=session("community_id")
cmd("@username")=request("userid")
cmd("@password")=request("userid")
cmd.execute
dim result
result=cmd("@result")
conn.close
if trim(result)="1" then
'''''''''''''登錄成功的提示與操作
else
''''''''''''''''''''''登錄失敗的提示與操作
end if
相關(guān)文章
adodb.recordset.open(rs.open)方法參數(shù)詳解
這篇文章主要介紹了adodb.recordset.open(rs.open)方法參數(shù)詳解,需要的朋友可以參考下2015-12-12
純編碼實(shí)現(xiàn)Access數(shù)據(jù)庫(kù)的建立或壓縮
純編碼實(shí)現(xiàn)Access數(shù)據(jù)庫(kù)的建立或壓縮...2006-06-06
ASP編程入門(mén)進(jìn)階(九):內(nèi)置對(duì)象Application
ASP編程入門(mén)進(jìn)階(九):內(nèi)置對(duì)象Application...2007-01-01
ASP編程入門(mén)進(jìn)階(二):認(rèn)識(shí)表單
ASP編程入門(mén)進(jìn)階(二):認(rèn)識(shí)表單...2007-01-01
查看所有的Server Variables的環(huán)境變量
查看所有的Server Variables的環(huán)境變量...2007-02-02
aspjpeg是一款非常強(qiáng)大的圖片處理組件,純英文版本。不過(guò)早已經(jīng)有免費(fèi)版和破解版,但是對(duì)其進(jìn)行詳細(xì)與深入介紹的文章卻是不多,即使有也只牽涉到圖片縮略和圖片水印??赡苁且?yàn)榧冇⑽牡木壒?/div> 2006-06-06
asp實(shí)現(xiàn)防止站外提交內(nèi)容的兩個(gè)方法
asp實(shí)現(xiàn)防止站外提交內(nèi)容的兩個(gè)方法...2007-01-01最新評(píng)論

