📄 通用数据库显示程序.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0046)http://www.aspsky.net/article/list.asp?id=2649 -->
<HTML><HEAD><TITLE>通用数据库显示程序|http://www.aspsky.net</TITLE>
<META content="text/html; charset=gb2312" http-equiv=Content-Type><LINK
href="通用据示程序http--www_aspsky_net.files/style.css" rel=stylesheet>
<META content="MSHTML 5.00.2919.6307" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff topMargin=2 marginheight="4">
<CENTER>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=755>
<TBODY>
<TR>
<TD class=p2 width=466><LINK
href="通用据示程序http--www_aspsky_net.files/style.css" rel=stylesheet>
<META content="Microsoft FrontPage 4.0" name=GENERATOR>
<TABLE align=center border=0 cellPadding=0 cellSpacing=0 width=755>
<TBODY>
<TR>
<TD height=54 width=181><IMG border=0 height=60
src="通用据示程序http--www_aspsky_net.files/LOGO.gif" width=181></TD>
<TD align=middle class=p2 height=70 width=492>
<DIV id=flash2 style="VISIBILITY: visible; Z-INDEX: -1"><A
href="http://www.ruixun.net/index.htm" target=_blank><IMG border=0
height=60 src="通用据示程序http--www_aspsky_net.files/ad1.gif"
width=468></A></DIV></TD>
<TD align=middle class=p2 style="LINE-HEIGHT: 150%" width=82><BR><A
href="http://www.aspsky.net/tell.asp">联系方法</A></TD></TR>
<TR>
<TD height=8 width=181></TD>
<TD class=p2 width=492></TD>
<TD class=p2 width=82></TD></TR></TBODY></TABLE>
<TABLE align=center border=0 cellPadding=0 cellSpacing=0 width=755>
<TBODY>
<TR>
<TD colSpan=3 height=22>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=738>
<TBODY>
<TR>
<TD align=middle
background=通用据示程序http--www_aspsky_net.files/top01.gif height=30
width=81><B><FONT color=#ffffff><IMG height=15
src="通用据示程序http--www_aspsky_net.files/dstop.gif" width=1><A
class=lb href="http://www.aspsky.net/">动网首页</A></FONT></B></TD>
<TD align=middle
background=通用据示程序http--www_aspsky_net.files/top02.gif
width=82><FONT color=#719bc1><B><FONT color=#ffffff><IMG
height=15 src="通用据示程序http--www_aspsky_net.files/dstop.gif"
width=1></FONT><A class=lb
href="http://www.dvbbs.net/">动网论坛</A></B></FONT></TD>
<TD align=middle
background=通用据示程序http--www_aspsky_net.files/top02.gif
width=82><FONT color=#719bc1><B><FONT color=#ffffff><IMG
height=15 src="" width=1></FONT><A class=lb
href="http://www.aspsky.net/article/index.asp?classid=2">ASP技术</A></B></FONT></TD>
<TD align=middle
background=通用据示程序http--www_aspsky_net.files/top02.gif
width=82><FONT color=#719bc1><B><FONT color=#ffffff><IMG
height=15 src="通用据示程序http--www_aspsky_net.files/dstop.gif"
width=1></FONT><A class=lb
href="http://www.aspsky.net/article/index.asp?classid=1">.NET专区</A></B></FONT></TD>
<TD align=middle
background=通用据示程序http--www_aspsky_net.files/top02.gif
width=82><FONT color=#719bc1><B><FONT color=#ffffff><IMG
height=15 src="通用据示程序http--www_aspsky_net.files/dstop.gif"
width=1></FONT><A class=lb
href="http://www.aspsky.net/article/index.asp?classid=5">数据库</A></B></FONT></TD>
<TD align=middle
background=通用据示程序http--www_aspsky_net.files/top02.gif
width=82><FONT color=#719bc1><B><FONT color=#ffffff><IMG
height=15 src="通用据示程序http--www_aspsky_net.files/dstop.gif"
width=1></FONT><A class=lb
href="http://www.aspsky.net/article/index.asp?classid=3">PHP技术</A></B></FONT></TD>
<TD align=middle
background=通用据示程序http--www_aspsky_net.files/top02.gif
width=82><FONT color=#719bc1><B><FONT color=#ffffff><IMG
height=15 src="通用据示程序http--www_aspsky_net.files/dstop.gif"
width=1></FONT><A class=lb
href="http://www.aspsky.net/article/index.asp?classid=4">JAVA技术</A></B></FONT></TD>
<TD align=middle
background=通用据示程序http--www_aspsky_net.files/top02.gif
width=82><FONT color=#719bc1><B><FONT color=#ffffff><IMG
height=15 src="通用据示程序http--www_aspsky_net.files/dstop.gif"
width=1></FONT><A class=lb
href="http://www.aspsky.net/download/index.asp">下载中心</A></B></FONT></TD>
<TD align=middle
background=通用据示程序http--www_aspsky_net.files/top02.gif
width=82><FONT color=#719bc1><B><FONT color=#ffffff><IMG
height=15 src="通用据示程序http--www_aspsky_net.files/dstop.gif"
width=1></FONT><A class=lb
href="http://www.aspsky.net/itrade/index.asp">项目交易</A></B></FONT></TD></TR></TBODY></TABLE></TD></TR>
<TR bgColor=#2b7eff>
<TD bgColor=#2b7eff width=64><IMG height=23 src="" width=5></TD>
<TD bgColor=#2b7eff width=343><FONT color=#0000ff><FONT
color=#3399ff><FONT color=#ccffff>
<SCRIPT language=JavaScript>
var today = new Date();
var strDate = (today.getFullYear() + "年" +
(today.getMonth() + 1) + "月" + today.getDate() + "日 ");
var n_day = today.getDay();
switch (n_day)
{
case 0:{
strDate = strDate + "星期日"
}break;
case 1:{
strDate = strDate + "星期一"
}break;
case 2:{
strDate = strDate + "星期二"
}break;
case 3:{
strDate = strDate + "星期三"
}break;
case 4:{
strDate = strDate + "星期四"
}break;
case 5:{
strDate = strDate + "星期五"
}break;
case 6:{
strDate = strDate + "星期六"
}break;
case 7:{
strDate = strDate + "星期日"
}break;
}
document.write(strDate);
</SCRIPT>
</FONT></FONT></FONT></TD>
<TD align=middle width=385><FONT color=#ccffff><IMG align=absMiddle
height=15 src="通用据示程序http--www_aspsky_net.files/home.gif" width=15>
</FONT><A href="http://www.aspsky.net/#"
onclick='this.style.behavior="url(#default#homepage)";this.setHomePage("http://www.aspsky.net")'
target=_self><FONT color=#ccffff>设为首页</FONT></A><FONT color=#ccffff>
<IMG align=absMiddle height=15
src="通用据示程序http--www_aspsky_net.files/favorite.gif" width=15>
</FONT><A
href="javascript:window.external.AddFavorite('http://www.aspsky.net','动网先锋(www.aspsky.net)')"
target=_self><FONT color=#ccffff>加入收藏</FONT></A><FONT color=#ccffff>
<IMG align=absMiddle height=15
src="通用据示程序http--www_aspsky_net.files/email.gif" width=15><A
href="http://www.dvbbs.net/" target=_top><FONT
color=#ccffff>会员中心</A></FONT></FONT></TD></TR></TBODY></TABLE>
<TABLE align=center border=0 cellPadding=0 cellSpacing=0 width=755>
<TBODY>
<TR bgColor=#3366ff>
<TD height=2></TD></TR></TBODY></TABLE>
<CENTER></CENTER></TD>
<TD class=p2 width=102></TD></TR></TBODY></TABLE>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=755>
<TBODY>
<TR>
<TD height=1></TD></TR>
<TR bgColor=#ffcc00>
<TD align=right height=23 width=355>
<CENTER></CENTER>
<P align=center>中国动感资源交流,网络动感资源荟萃</P></TD>
<TD align=middle>
<P align=center><A href="http://www.moonet.com/edu/">教育网</A>
英文版</P></TD></TR></TBODY></TABLE>
<CENTER>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=755>
<TBODY>
<TR vAlign=top>
<TD bgColor=#297dff width=1> </TD>
<TD width=753></TD>
<TD bgColor=#297dff width=1> </TD></TR></TBODY></TABLE>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=755>
<TBODY>
<TR vAlign=top>
<TD bgColor=#297dff width=1> </TD>
<TD width=753>
<TABLE border=0 cellPadding=0 cellSpacing=0 width="100%">
<TBODY>
<TR>
<TD bgColor=#297dff colSpan=2 height=20><FONT color=#ceffff> →
<A href="http://www.aspsky.net/article/index.asp?classid=2"><FONT
color=#ceffff>ASP技术</FONT></A> >> <A
href="http://www.aspsky.net/article/index.asp?classid=2&Nclassid=10"><FONT
color=#ceffff>数据库相关</FONT></A> >> 《通用数据库显示程序》</FONT></TD></TR>
<TR>
<TD bgColor=#586011 colSpan=2 height=1><SPACER type="block"
width="1"></TD></TR>
<TR>
<TD colSpan=2 height=7></TD></TR>
<TR>
<TD align=middle class=p4
colSpan=2><B>通用数据库显示程序</B></FONT><BR>2002-3-12 动网先锋
</TD></TR>
<TR>
<TD class=p4 colSpan=2>
<BLOCKQUOTE><BR>数据库显示程序,能调任意库,任意字段,多关键字搜索,自动分页.
<P></P>
<P><BR>阿余经常写一些数据库相关的程序,当然离不开显示库中的数据了,说实话,做这样的程序真是无聊啊,所以,阿余就想写个函数,一个通用的数据库显示函数.要求如下:
</P>
<P>1. 能显示指定的字段,当然,字段名和显示的文字可以不一样. <BR>2.
能同时按多个字段进行查询,支持模糊和精确两种查询方式. <BR>3. 有横向排列和纵向排列字段两种显示方式. <BR>4.
能自动分页. <BR>5. 能设定每页显示多少条记录.好啦,要求大至就是这样了.根据这个要求,阿余写了下面的函数.
<BR>实际上,这里阿余写了两个函数.一个是TABDISP(),用于显示一个指定表中的内容.还有一个是ER()一个小小的错误处理函数.
<BR>这个函数有5个参数(真够多的).并且各个参数都要输入数据,不能是空白,不然会出错的. <BR>1(TAB), 要调用的表名.
<BR>2(DISPFILD),
要显示表中的哪一些字段,如字段名和要显示的字符不一样用<分隔.比如某一个字段名为:IMG,但要在页面上显示为:图片,
那么,就写为IMG<图片,如果有多个字段,各字段间用“,”分隔,唉,老声长谈. <BR>3(FINDFILD),
要按哪些字段进行查询,字段名和要显示的字符间用<分隔. <BR>4(PAGEN), 每页显示多少条记录. <BR>5(FH),
显示的方向.当为S时纵向显示.为H时横向显示. <BR>函数的返回值,当没有出错的时候,返回值为真,否则为假.
<BR>这个函数中没有包括连接到数据库的部分.所以要自己连接到库.另外,为了重复应用.可以把这个函数专门用一个文件来保存,然后在需要的时候包含这个文件.
<BR>看下面的函数: (不要不看完,最后我举有应用的例子) </P>
<P><%
<BR>'以下定义一个显示表格的函数TABDISP(),参数TAB,被显示的表名,DISPFILD,要显示的字段,FINDFILD,查询字段,PAGEN,每页显示数量,fh,显示的方向
<BR>'如显示成功,返回值为真,不成功,返回值为假. <BR>'多个字段间用,分隔 <BR>'查询字段一定要包含在显示字段中.
<BR>'如字段名与要显示的名称不一样,用<分隔,前面是字段名,后面是显示的名字,而要进行搜索的字段则一定要用<分隔要字段名和显示字符
<BR>'FH显示方向为"H"时作横向显示,为"S"时作纵向显示 区分大小写 <BR>FUNCTION
TABDISP(TAB,DISPFILD,FINDFILD,PAGEN,FH) <BR>On Error Resume Next
<BR>IF DISPFILD="" THEN DISPFILD="*" <BR>IF PAGEN="" THEN PAGEN=15
<BR>DISPFILD1=DISPFILD&"," <BR>findfild1=findfild&"," </P>
<P>dim findl(10),findr(10) <BR>i1=1 <BR>do while
instr(findfild1,",")<>0 <BR>star=instr(findfild1,",")
<BR>findl(i1)=left(findfild1,star-1) <BR>findr(i1)=findl(i1)
<BR>fildbak=findl(i1)
<BR>findl(i1)=left(fildbak,instr(fildbak,"<")-1)
<BR>findr(i1)=right(fildbak,len(fildbak)-instr(fildbak,"<"))
<BR>findfild1=right(findfild1,len(findfild1)-star) <BR>i1=i1+1
<BR>loop </P>
<P>Response.Write "<table border='0' width='100%'
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -