今天是: + 登录 + 注册 + 控制面板 + 加入收藏 + 设为首页 + +
  →采集系统演示  →娱乐社区演示站    →BT下载  
顾客至上,信誉第一 首页 · 新闻公告 · 下载中心 · 帮助中心 · 产品购买 · 主机空间 · 网络学院 · 技术论坛 · 网站建设
")
end select
if (i mod loopnum=0) then
response.write""
end if
rs.movenext
next
response.Write("
推荐下载
SK信息采集+风讯CMSV4.0 Sp5整
SK信息采集(科汛CMS)整合版3.3
SK信息采集系统V3.3版(单机版)
SK信息采集系统V3.2版 
SK信息采集系统(单机)版V3.1 B
SK信息采集整合(科汛CMS)插件V
SK产品
 
技术文章
SK信息采集安装教程(单机版)
图片采集规则操作演示
sk信息采集3.0视频教程
SK信息采集系统简介
信息采集方案
新闻采集帮助
SK采集基本使用帮助
购买指南
购买步骤
汇款方式
功能对比
产品报价
版本历史
联系我们
购买咨询QQ:软件购买咨询询留言
技术服务QQ:技术服务
手机:(0)13860892492(购买咨询)
电话: 0596-2821043(售后技术服务)
联系邮箱:skxiu2006@sina.com
友情链接

  科汛网络  风讯CMS   网行天下
  中国站长  中国2399分类网

当前位置:SK网络 >> 网络学院 >> ASP专区 >> 浏览文章
")
case "2"
response.Write("")
response.Write(rs(""&fildname&""))
response.Write("
")
response.Write("")
response.Write("方式2之"&i&"记录")
response.Write("
")
response.Write("
ASP应用中的应用函数

1,经常写些系统,那么一般都是从登录程序开始,每接一个系统就写一次登录,好麻烦。

干脆直接做个登录验证函数吧,对我来说,大都情况可以胜任了:)



<%
Function chk_regist(requestname,requestpwd,tablename,namefield,pwdfield,reurl)
dim cn_name,cn_pwd
cn_name=trim(request.form(""&requestname&""))
cn_pwd=trim(request.form(""&requestpwd&""))
if cn_name="" or cn_pwd="" then
response.Write("alert(""请将帐号密码填写完整,谢谢合作。"");history.go(-1)")
end if
Set rs = Server.CreateObject ("ADODB.Recordset")
sql = "Select * from "&tablename&" where "&namefield&"='"&cn_name&"'"
rs.open sql,conn,1,1
if rs.eof then
response.Write("alert(""没有该会员ID,请确认有没有被申请。"");history.go(-1)")
else
if rs(""&pwdfield&"")=cn_pwd then 
session("cn_name")=rs(""&namefield&"")
response.Redirect(reurl)
else
response.Write("alert(""提醒,您的帐号和密码是不吻合。注意数字和大小写。"");history.go(-1)")
end if
end if
rs.close 
Set rs = Nothing
End Function
%>



参数说明:
chk_regist(requestname,requestpwd,tablename,namefield,pwdfield,reurl)

requestname 为接受HTML页中输入名称的INPUT控件名
requestpwd 为接受HTML页中输入密码的INPUT控件名
tablename 为数据库中保存注册信息的表名
namefield 为该信息表中存放用户名称的字段名
pwdfield 为该信息表中存放用户密码的字段名
reurl 为登录正确后跳转的页

引用示例如下:



<%
call chk_regist("b_name","b_pwd","cn_admin","cn_name","cn_pwd","admin.asp")
%>


调试地址:http://www.cnbruce.com/test/function/regist.asp


2,经常有可能对某个事物进行当前状态的判断,一般即做一字段(数值类型,默认值为0)
通过对该字段值的修改达到状态切换的效果。那么,我又做了个函数,让自己轻松轻松。



<%
Function pvouch(tablename,fildname,autoidname,indexid)
dim fildvalue
Set rs = Server.CreateObject ("ADODB.Recordset")
sql = "Select * from "&tablename&" where "&autoidname&"="&indexid
rs.Open sql,conn,2,3
fildvalue=rs(""&fildname&"")
if fildvalue=0 then
fildvalue=1
else
fildvalue=0
end if
rs(""&fildname&"")=fildvalue
rs.update
rs.close 
Set rs = Nothing
End Function
%>



参数说明:
pvouch(tablename,fildname,autoidname,indexid)

tablename 该事物所在数据库中的表名
fildname 该事物用以表明状态的字段名(字段类型是数值型)
autoidname 在该表中的自动编号名
indexid 用以修改状态的对应自动编号的值

引用示例如下:


<%
dowhat=request.QueryString("dowhat")
p_id=cint(request.QueryString("p_id"))

if dowhat="tj" and p_id<>"" then
call pvouch("cn_products","p_vouch","p_id",p_id)
end if
%>

<%if rs("p_vouch")=0 then%>
>推荐
<%else%>
>取消推荐
<%end if%>



调试地址:http://www.cnbruce.com/test/function/showpro.asp

3,为很多中小企业写站点,一般产品展示是个大项目,那么做成的页面也就不同。
要不就是横排来几个,要不就是竖排来几个,甚至全站要翻来覆去的搞个好几次,麻烦也很累。
索性写个函数能缓解一下,于是就成了下面


"
end if
select case typenum
case "1"
response.Write("")
response.Write(rs(""&fildname&""))
response.Write("")
response.Write("方式1之"&i&"记录")'此处的“方式1”可以替换显示为其余字段的值
response.Write("
")'如果字段比较多,继续添加新个表格行来显示
response.Write("

<%
function showpros(tablename,topnum,fildname,loopnum,typenum)
Set rs = Server.CreateObject ("ADODB.Recordset")
sql = "Select top "&topnum&" * from "&tablename
rs.Open sql,conn,1,1
if rs.eof and rs.bof then
response.Write("暂时无该记录")
else
response.Write("")
for i=1 to rs.recordcount
if (i mod loopnum=1) then
response.write"

")
end if
rs.close 
Set rs = Nothing
end function
%>



参数说明:showpros(tablename,topnum,fildname,loopnum,typenum)

whichpro为选择何类型的产品种类
topnum表示提取多少条记录
fildname表示调试显示的字段,具体应用的时候可以省去该参数,在函数内部直接使用
loopnum表示显示的循环每行的记录条数
typenum表示循环显示的方法:目前分了两类,横向并列、纵向并列显示同一数据记录行的不同记录

引用示例如下:


<%
if request.form("submit")<>"" then
topnum=request.form("topnum")
loopnum=request.form("loopnum")
typenum=request.form("typenum")
else
topnum=8
loopnum=2
typenum=1
end if
%>
<%call showpros("cn_products",topnum,"p_name",loopnum,typenum)%>

显示的记录总数:>
显示的行循环数:>
显示的方式类型:
方式1
方式2





发表评论】【告诉好友】【打印此文】【收藏此文】【关闭窗口
[2007年03月14日]   来源:不详     【字体: 】【双击滚屏
上一篇:ASP中使用存储过程 下一篇:没有了
 
Copyright © 2006-2008 Skxiu.com

 版权所有 © 2006-2008 SK网络 www.skxiu.com 闽ICP备 06016779号