打印本文 打印本文  关闭窗口 关闭窗口  
一个存储过程完成插入,更新,删除,登录,审核,取消等等功能
作者:灌水公司  文章来源:不详  点击数  更新时间:2003/9/7 22:58:37  文章录入:ahui  责任编辑:ahui

一个存储过程完成插入,更新,删除,登录,审核,取消等等功能
[原创]一个存储过程完成插入,更新,删除,登录,审核,取消等等功能
灌水公司荣誉出品

1.数据表
CREATE TABLE [Nta_our_travelco] (
[travelco_id] [int] IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL ,
[travelco_name] [varchar] (80) COLLATE Chinese_PRC_CI_AS NULL ,
[travelco_linkman] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[travelco_phone] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[travelco_mobile] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[travelco_check] [char] (1) COLLATE Chinese_PRC_CI_AS NULL ,
[travelco_website] [varchar] (80) COLLATE Chinese_PRC_CI_AS NULL ,
[travelco_email] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[travelco_fax] [char] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[travelco_address] [varchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
[travelco_intro] [varchar] (1000) COLLATE Chinese_PRC_CI_AS NULL ,
[travelco_TLicenseNo] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL CONSTRAINT

[DF_Nta_our_travelco_travelco_TLicenseNo] DEFAULT ('交观甲号'),
[travelco_QLicenseNo] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL CONSTRAINT

[DF_Nta_our_travelco_travelco_QLicenseNo] DEFAULT ('品保(北)字号'),
[travelco_ename] [varchar] (80) COLLATE Chinese_PRC_CI_AS NULL ,
[travelco_LicenseNo] [varchar] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[travelco_AgentCEO] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[username] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[password] [varchar] (32) COLLATE Chinese_PRC_CI_AS NULL ,
CONSTRAINT [PK_Nta_our_travelco] PRIMARY KEY CLUSTERED
(
[travelco_id]
) ON [PRIMARY]
) ON [PRIMARY]
GO


2.存储过程
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

ALTER PROCEDURE Nta_our_travelco_Update
@action int,
@travelco_id int =null,
@travelco_name varchar(80) =null,
@travelco_linkman varchar(20) =null,
@travelco_phone varchar(20) =null,
@travelco_mobile varchar(20) =null,
@travelco_website varchar(80) =null,
@travelco_email varchar(50) =null,
@travelco_fax char(20) =null,
@travelco_address varchar(200) =null,
@travelco_intro varchar(500) =null,
@travelco_TLicenseNo varchar(30) =null,
@travelco_QLicenseNo varchar(30) =null,
@travelco_ename varchar(80) =null,
@travelco_LicenseNo varchar(10) =null,
@travelco_AgentCEO varchar(20) =null,
@username varchar(20)=null,
@password varchar(32)=null,
@sessionid int=null, --管理员session
@password_md5 varchar(32)
AS

if @action=1 ---同行注册
begin
if exists(select * from Nta_our_travelco where username = @username)
select 10 --用户存在
else --用户不存在,快速注册
begin
insert into Nta_our_travelco(
travelco_name ,
travelco_linkman ,
travelco_phone ,
travelco_mobile ,
travelco_website ,
travelco_email ,
travelco_fax ,
travelco_address ,
travelco_intro ,
travelco_TLicenseNo ,
travelco_QLicenseNo ,
travelco_ename ,
travelco_LicenseNo ,
travelco_AgentCEO,username,password
)
values(
@travelco_name ,
@travelco_linkman ,
@travelco_phone ,
@travelco_mobile ,
@travelco_website ,
@travelco_email ,
@travelco_fax ,
@travelco_address ,
@travelco_intro ,
@travelco_TLicenseNo ,
@travelco_QLicenseNo ,
@travelco_ename ,
@travelco_LicenseNo ,
@travelco_AgentCEO,@username,@password_md5
)
select 1 --注册成功
end
end

if @action=2 --同行修改注册信息
update Nta_our_travelco set
travelco_id = @travelco_id ,
travelco_name = @travelco_name ,
travelco_linkman = @travelco_linkman ,
travelco_phone = @travelco_phone ,
travelco_mobile = @travelco_mobile ,
travelco_website = @travelco_website ,
travelco_email = @travelco_email ,
travelco_fax = @travelco_fax ,
travelco_address = @travelco_address ,
travelco_intro = @travelco_intro ,
travelco_TLicenseNo = @travelco_TLicenseNo ,
travelco_QLicenseNo = @travelco_QLicenseNo ,
travelco_ename = @travelco_ename ,
travelco_LicenseNo = @travelco_LicenseNo ,
travelco_AgentCEO = @travelco_AgentCEO
where
travelco_id = @travelco_id
select 2 --更新成功

if @action=3 --审核同行
if @sessionid=null
begin
select 5 --不是管理员ID,无法审核同行
end
else
begin
update Nta_our_travelco set
travelco_check = 1
where
travelco_id = @travelco_id
select 3 --审核通过
end

if @action=4 --取消同行
if @sessionid=null
begin
select 6 --不是管理员ID,无法取消同行
end
else
begin
update Nta_our_travelco set
travelco_check = 0
where
travelco_id = @travelco_id
select 4 --取消成功
end

if @action=5 --同行登录
begin
if not exists(select * from Nta_our_travelco where username = @username)
select 11 --用户不存在
else
begin
declare @pwd char(32)
select @pwd=password from Nta_our_travelco where username = @username
if @pwd=@password_md5
select 12 --登录成功
else
begin
select 13 --密码错误
--select @userid = -1
end

end
end

if @action=6 --同行更改密码
update Nta_our_travelco set
password = @password_md5
where
travelco_id = @travelco_id
select 14 --更改密码成功
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

3.asp调用
<%
'省略数据库调用
'action,travelco_id,travelco_name等等的参数自己定义!

set rs=server.CreateObject ("adodb.recordset")
set cm=Server.CreateObject("Adodb.Command")
cm.parameters(1) = action
cm.parameters(2) = travelco_id
cm.parameters(3) = travelco_name
cm.parameters(4) = travelco_linkman
cm.parameters(5) = travelco_phone
cm.parameters(6) = travelco_mobile
cm.parameters(7) = travelco_check
cm.parameters(8) = travelco_website
cm.parameters(9) = travelco_email
cm.parameters(10) = travelco_fax
cm.parameters(11) = travelco_address
cm.parameters(12) = travelco_intro
cm.parameters(13) = travelco_TLicenseNo
cm.parameters(14) = travelco_QLicenseNo
cm.parameters(15) = travelco_ename
cm.parameters(16) = travelco_LicenseNo
cm.parameters(17) = travelco_AgentCEO
cm.parameters(18) = username
cm.parameters(19) = password
cm.parameters(20) = sessionid
cm.parameters(21) = password_md5
rs.CursorLocation=3
rs.LockType=3
rs.Open cm

if rs(0)=1 then
str="注册成功"

elseif rs(0)=2 then
str="更新成功"

elseif rs(0)=3 then
str="审核通过"

elseif rs(0)=4 then
str="取消成功"

elseif rs(0)=5 then
str="不是管理员ID,无法审核同行"

elseif rs(0)=6 then
str="不是管理员ID,无法取消同行"

elseif rs(0)=10 then
str="用户存在"

elseif rs(0)=11 then
str="不是管理员ID,无法取消同行"

elseif rs(0)=12 then
str="登录成功"

elseif rs(0)=13 then
str="密码错误"

elseif rs(0)=14 then
str="更改密码成功"

end if

response.write str
response.end
%>

◇ 广告时间:
数据库代码,文档由86fifa编写整理。
灌水公司提供专业级的网站程序开发,数据库开发,收费技术支持、安全顾问服务


打印本文 打印本文  关闭窗口 关闭窗口