设置VBA,根据excle sheet 文件夹“ALL”sheet中的AO列开头两个字母,将内容自动粘贴到对应的小表中

ASP常见问题及解答征集中,请大家积极参与~~~~~~~~-CSDN论坛
ASP常见问题及解答征集中,请大家积极参与~~~~~~~~
征集常见问题及解决方法,禁止灌水,否则将删除!
分&&&&类:XXX(请参照FAQ)
问题描述:XXX
解决办法:XXX
1.如何&最小化、最大化、关闭窗口
答:&objectid=hh1classid="clsid:adb880a6-d8ff-11cf-3b7a11"&
&paramname="command"value="minimize"&&/object&
&objectid=hh2classid="clsid:adb880a6-d8ff-11cf-3b7a11"&
&paramname="command"value="maximize"&&/object&
&objectid=hh3classid="clsid:adb880a6-d8ff-11cf-3b7a11"&
&paramname="command"value="close"&&/object&
&inputtype=buttonvalue=最小化onclick=hh1.click()&
&inputtype=buttonvalue=最大化onclick=hh2.click()&
&inputtype=buttonvalue=关闭onclick=hh3.click()&
2.如何静止页面缓存
答:htm网页
&metahttp-equiv="pragma"content="no-cache"&
&metahttp-equiv="cache-control"content="no-cache,must-revalidate"&
&metahttp-equiv="expires"content="wed,26feb:57gmt"&
或者&metahttp-equiv="expires"content="0"&
response.expires=-1
response.expiresabsolute=now()-1
response.cachecontrol="no-cache"
header("expires:mon,26jul:00gmt");
header("cache-control:no-cache,must-revalidate");
header("pragma:no-cache");
3.如何检查一段字符串是否全由数字组成
&scriptlanguage="javascript"&&!--
functionchecknum(str){returnstr.match(/\d/)==null}
alert(checknum(""))
alert(checknum(""))
//--&&/script&
4.如何获取机器信息
答本机ip&%=request.servervariables("remote_addr")%&
服务器名&%=request.servervariables("server_name")%&
服务器ip&%=request.servervariables("local_addr")%&
服务器端口&%=request.servervariables("server_port")%&
服务器时间&%=now%&
iis版本&%=request.servervariables"server_software")%&
脚本超时时间&%=server.scripttimeout%&
本文件路径&%=server.mappath(request.servervariables("script_name"))%&
服务器cpu数量&%=request.servervariables("number_of_processors")%&
服务器解译引擎&%=scriptengine&"/"&&&scriptenginemajorversion&&"."&&&scriptengineminorversion&&&"."&&&scriptenginebuildversion%&
服务器操作系统&%=request.servervariables("os")%&
1.如何让日期相减
日期减去天数等于第二个日期
&scriptlanguage=javascript&
functioncc(dd,dadd)
//可以加上错误处理
vard=newdate(dd.replace("-","/"))
d.setdate(d.getdate()+dadd)
alert(d.getfullyear()+"年"+(d.getmonth()+1)+"月"+d.getdate()+"日")
1.怎样通过asp的手段来检查来访者是否用了代理
&%ifrequest.servervariables("http_x_forwarded_for")&&""then
response.write"&fontcolor=#ff0000&您通过了代理服务器,"&_
"真实的ip为"&request.servervariables("http_x_forwarded_for")
分类:&&&&错误及常见错误代码
问题描述:&网页错误,无法显示。
解决办法:
1)&服务器端配置&iis&中&“允许客户端调试”,“发送具体的asp&错误"
2)&客户端&ie&-&&工具&-&&Internet&选项&-&&高级&-&&把&"显示友好http&错误”这个选项去掉
这样就能看到错误信息了。
获得窗口的大小
document.body.clientWidth,document.body.clientHeight
document.body.offsetWidth,document.body.offsetHeight
判断一个表是否存在:
if&exists&(select&*&from&dbo.sysobjects&where&id&=&object_id('表名')&and&OBJECTPROPERTY(id,&N'IsUserTable')&=&1)
drop&table&表名
从publish&表中取出第&n&条到第&m&条的记录:&
SELECT&TOP&m-n+1&*&
FROM&publish&
WHERE&(id&NOT&IN&
     (SELECT&TOP&n-1&id&
    &FROM&publish))&
id&为publish&表的关键字
分类:&&&&js程序
1.如何实现连续滚动
&div&id="marquees"&&br/&&br/&
数据里面读出来的&br/&
&script&language="JavaScript"&
marqueesHeight=200;
stopscroll=
with(marquees){
&&style.width=0;
&&style.height=marqueesH
&&style.overflowX="visible";
&&style.overflowY="hidden";
&&onmouseover=new&Function("stopscroll=true");
&&onmouseout=new&Function("stopscroll=false");
document.write('&div&id="templayer"&style="position:z-index:1;visibility:hidden"&&/div&');
preTop=0;&currentTop=0;&
function&init(){
&&templayer.innerHTML="";
&&while(templayer.offsetHeight&marqueesHeight){
&&&&templayer.innerHTML+=marquees.innerHTML;
&&marquees.innerHTML=templayer.innerHTML+templayer.innerHTML;
&&setInterval("scrollUp()",10);
document.body.onload=
function&scrollUp(){
&&if(stopscroll==true)&
&&preTop=marquees.scrollT
&&marquees.scrollTop+=1;
&&if(preTop==marquees.scrollTop){
&&&&marquees.scrollTop=templayer.offsetHeight-marqueesH
&&&&marquees.scrollTop+=1;
只针对图片:
&form&name=form1&onsubmit="return&mm()"&
&input&type=file&name=meizz&&br/&
&input&type=submit&value=submit&&/form&
&SCRIPT&LANGUAGE="JavaScript"&&!--
function&mm()
&&var&s&=&document.form1.meizz.
&&if(s=="")return&
&&var&img&=&new&Image();
&&img.src&=&s;
&&alert("高&=&"+&img.height&+&"\n宽&=&"+&img.width);
&&alert("fileSize&=&"+&img.fileSize&+"&字节");
&&return(img.fileSize&&=&40000);
//--&&/SCRIPT&
1.&oncontextmenu="window.event.returnvalue=false"&将彻底屏蔽鼠标右键
&table&border&oncontextmenu=return(false)&&td&no&/table&&可用于Table
2.&&body&onselectstart="return&false"&&取消选取、防止复制
3.&onpaste="return&false"&不准粘贴
4.&oncopy="return&"&oncut="return&"&防止复制
5.&&link&rel="Shortcut&Icon"&href="favicon.ico"&&IE地址栏前换成自己的图标
6.&&link&rel="Bookmark"&href="favicon.ico"&&可以在收藏夹中显示出你的图标
7.&&input&style="ime-mode:disabled"&&关闭输入法
8.&永远都会带着框架
&script&language="javascript"&&!--
if&(window&==&top)top.location.href&=&"frames.htm";&//frames.htm为框架网页
//&--&&/script&
9.&防止被人frame
&SCRIPT&LANGUAGE=javascript&&!--&
if&(top.location&!=&self.location)top.location=self.
//&--&&/SCRIPT&
10.&&noscript&&iframe&src=*.html&&/iframe&&/noscript&&网页将不能被另存为
11.&&input&type=button&value=查看网页源代码&
onclick="window.location&=&'view-source:'+&'http://www.csdn.net/'"&
12.&怎样通过asp的手段来检查来访者是否用了代理
&%&if&Request.ServerVariables("HTTP_X_FORWARDED_FOR")&&""&then
response.write&"&font&color=#FF0000&您通过了代理服务器,"&&_
"真实的IP为"&Request.ServerVariables("HTTP_X_FORWARDED_FOR")
13.&取得控件的绝对位置
//javascript
&script&language="javascript"&
function&getIE(e){
var&t=e.offsetT
var&l=e.offsetL
while(e=e.offsetParent){
t+=e.offsetT
l+=e.offsetL
alert("top="+t+"\nleft="+l);
//VBScript
&script&language="VBScript"&&!--
function&getIE()
dim&t,l,a,b
set&a=document.all.img1
t=document.all.img1.offsetTop
l=document.all.img1.offsetLeft
while&a.tagName&&"BODY"
set&a&=&a.offsetParent
t=t+a.offsetTop
l=l+a.offsetLeft
msgbox&"top="&t&chr(13)&"left="&l,64,"得到控件的位置"
end&function
--&&/script&
14.&光标是停在文本框文字的最后
&script&language="javascript"&
function&cc()
var&e&=&event.srcE
var&r&=e.createTextRange();
r.moveStart('character',e.value.length);
r.collapse(true);
r.select();
&input&type=text&name=text1&value="123"&onfocus="cc()"&
15.&判断上一页的来源
request.servervariables("HTTP_REFERER")
javascript:
document.referrer
16.&最小化、最大化、关闭窗口
&object&id=hh1&classid="clsid:ADB880A6-D8FF-11CF-3B7A11"&&
&param&name="Command"&value="Minimize"&&/object&
&object&id=hh2&classid="clsid:ADB880A6-D8FF-11CF-3B7A11"&&
&param&name="Command"&value="Maximize"&&/object&
&OBJECT&id=hh3&classid="clsid:adb880a6-d8ff-11cf-3b7a11"&
&PARAM&NAME="Command"&value="Close"&&/OBJECT&
&input&type=button&value=最小化&onclick=hh1.Click()&
&input&type=button&value=最大化&onclick=hh2.Click()&
&input&type=button&value=关闭&onclick=hh3.Click()&
本例适用于IE
'定义数据库连接的一些常量
Const&adOpenForwardOnly&=&0&'游标只向前浏览记录,不支持分页、Recordset、BookMark
Const&adOpenKeyset&=&1&'键集游标,其他用户对记录说做的修改将反映到记录集中,但其他用户增加或删除记录不会反映到记录集中。支持分页、Recordset、BookMark
Const&adOpenDynamic&=&2&'动态游标功能最强,但耗资源也最多。用户对记录说做的修改,增加或删除记录都将反映到记录集中。支持全功能浏览(ACCESS不支持)。
Const&adOpenStatic&=&3&'静态游标,只是数据的一个快照,用户对记录说做的修改,增加或删除记录都不会反映到记录集中。支持向前或向后移动
Const&adLockReadOnly&=&1&'锁定类型,默认的,只读,不能作任何修改
Const&adLockPessimistic&=&2&'当编辑时立即锁定记录,最安全的方式
Const&adLockOptimistic&=&3&'只有在调用Update方法时才锁定记录集,而在此前的其他操作仍可对当前记录进行更改、插入和删除等
Const&adLockBatchOptimistic&=&4&'当编辑时记录不会被锁定,而更改、插入和删除是在批处理方式下完成的
Const&adCmdText&=&&H0001
Const&adCmdTable&=&&H0002
18.&网页不会被缓存
&META&HTTP-EQUIV="pragma"&CONTENT="no-cache"&
&META&HTTP-EQUIV="Cache-Control"&CONTENT="no-cache,&must-revalidate"&
&META&HTTP-EQUIV="expires"&CONTENT="Wed,&26&Feb&:57&GMT"&
或者&META&HTTP-EQUIV="expires"&CONTENT="0"&
Response.Expires&=&-1
Response.ExpiresAbsolute&=&Now()&-&1
Response.cachecontrol&=&"no-cache"
header("Expires:&Mon,&26&Jul&:00&GMT");
header("Cache-Control:&no-cache,&must-revalidate");
header("Pragma:&no-cache");
19.&检查一段字符串是否全由数字组成
&script&language="javascript"&&!--
function&checkNum(str){return&str.match(/\D/)==null}
alert(checkNum(""))
alert(checkNum(""))
//&--&&/script&
20.&获得一个窗口的大小
document.body.clientWidth,document.body.clientHeight
21.&怎么判断是否是字符
if&(/[^\x00-\xff]/g.test(s))&alert("含有汉字");
else&alert("全是字符");
22.TEXTAREA自适应文字行数的多少
&textarea&rows=1&name=s1&cols=27&onpropertychange="this.style.posHeight=this.scrollHeight"&
&/textarea&
23.&日期减去天数等于第二个日期
&script&language=javascript&
function&cc(dd,dadd)
//可以加上错误处理
var&a&=&new&Date(dd)
a&=&a.valueOf()
a&=&a&-&dadd&*&24&*&60&*&60&*&1000
a&=&new&Date(a)
alert(a.getFullYear()&+&"年"&+&(a.getMonth()&+&1)&+&"月"&+&a.getDate()&+&"日")
cc("12/23/2002",2)
24.&选择了哪一个Radio
&HTML&&script&language="vbscript"&
function&checkme()
for&each&ob&in&radio1
if&ob.checked&then&window.alert&ob.value
end&function
&/script&&BODY&
&INPUT&name="radio1"&type="radio"&value="style"&checked&Style
&INPUT&name="radio1"&type="radio"&value="barcode"&Barcode
&INPUT&type="button"&value="check"&onclick="checkme()"&
&/BODY&&/HTML&
25.获得本页url的request.servervariables("")集合
Response.Write&"&TABLE&border=1&&!--&Table&Header&--&&TR&&TD&&B&Variables&/B&&/TD&&TD&&B&value&/B&&/TD&&/TR&"
for&each&ob&in&Request.ServerVariables
Response.Write&"&TR&&TD&"&ob&"&/TD&&TD&"&Request.ServerVariables(ob)&"&/TD&&/TR&"
Response.Write&"&/TABLE&"
本机ip&%=request.servervariables("remote_addr")%&
服务器名&%=Request.ServerVariables("SERVER_NAME")%&
服务器IP&%=Request.ServerVariables("LOCAL_ADDR")%&
服务器端口&%=Request.ServerVariables("SERVER_PORT")%&
服务器时间&%=now%&
IIS版本&%=Request.ServerVariables"SERVER_SOFTWARE")%&
脚本超时时间&%=Server.ScriptTimeout%&
本文件路径&%=server.mappath(Request.ServerVariables("SCRIPT_NAME"))%&
服务器CPU数量&%=Request.ServerVariables("NUMBER_OF_PROCESSORS")%&
服务器解译引擎&%=ScriptEngine&&&"/"&&ScriptEngineMajorVersion&&"."&ScriptEngineMinorVersion&"."&&ScriptEngineBuildVersion&%&
服务器操作系统&%=Request.ServerVariables("OS")%&
27.ENTER键可以让光标移到下一个输入框
&input&onkeydown="if(event.keyCode==13)event.keyCode=9"&
28.&检测某个网站的链接速度:
把如下代码加入&body&区域中:
&script&language=javascript&
setInterval("tim++",100)
var&autourl=new&Array()
autourl[1]="www.njcatv.net"
autourl[2]="javacool.3322.net"
autourl[3]=".cn"
autourl[4]="www."
autourl[5]=""
function&butt(){
document.write("&form&name=autof&")
for(var&i=1;i&autourl.i++)
document.write("&input&type=text&name=txt"+i+"&size=10&value=测试中……&&=》&input&type=text&name=url"+i+"&size=40&&=》&input&type=button&value=GO&onclick=window.open(this.form.url"+i+".value)&&br/&")
document.write("&input&type=submit&value=刷新&&/form&")
function&auto(url){
document.forms[0]["url"+b].value=url
if(tim&200)
{document.forms[0]["txt"+b].value="链接超时"}
{document.forms[0]["txt"+b].value="时间"+tim/10+"秒"}
function&run(){for(var&i=1;i&autourl.i++)document.write("&img&src=http://"+autourl[i]+"/"+Math.random()+"&width=1&height=1&onerror=auto('http://";+autourl[i]+"')&")}
run()&/script&
29.&各种样式的光标
auto&:标准光标
default&:标准箭头
hand&:手形光标
wait&:等待光标
text&:I形光标
vertical-text&:水平I形光标
no-drop&:不可拖动光标
not-allowed&:无效光标
help&:?帮助光标
all-scroll&:三角方向标
move&:移动标
crosshair&:十字标
键盘触发事件
http://expert.csdn.net/Expert/topic/.xml?temp=.3390619
http://expert.csdn.net/Expert/topic/.xml?temp=.5907099
outerHTML&and&innerHTML
http://expert.csdn.net/Expert/topic/.xml?temp=.2553369
列表框间选项间移动的脚本
http://expert.csdn.net/Expert/topic/.xml?temp=1.
限制只能输入数字和小数点
http://expert.csdn.net/Expert/topic/.xml?temp=.387417
无组件上传类
http://expert.csdn.net/Expert/topic/.xml?temp=.7916529
http://expert.csdn.net/Expert/topic/.xml?temp=.1580011
如何调用[文件另存为...&]对话框?
http://expert.csdn.net/Expert/topic/.xml?temp=.4600031
一个我刚刚学习asp时候天天看,天天学的例子,学了好长时间才精通这个程序
/asp/ute/ute_301.zip
/asp/ute.asp
一个我刚刚学习asp写日历程序时候的经典例子,也学习了2天,感觉很好
/asp/ezevents/EzEvents_src.zip
/asp/ezevents.asp
一句话:老外玩模块化编程就是牛,玩面向对象也是牛!而我!水牛!
强烈推荐xxrl(孔曰成仁,孟曰取E)的/xxrl.zip这个东西,东东多多啊
收藏中...................................
图片显示控制:
&script&language="JavaScript"&
function&DrawImage(ImgD){
&&&var&image=new&Image();
&&&image.src=ImgD.
&&&if(image.width&0&&&&image.height&0){
&&&&if(image.width/image.height&=&360/270){
&&&&&if(image.width&360){&&
&&&&&ImgD.width=360;
&&&&&ImgD.height=(image.height*360)/image.
&&&&&}else{
&&&&&ImgD.width=image.&&
&&&&&ImgD.height=image.
&&&&&ImgD.alt=image.width+"×"+image.
&&&&&if(image.height&270){&&
&&&&&ImgD.height=270;
&&&&&ImgD.width=(image.width*270)/image.&&&&&
&&&&&}else{
&&&&&ImgD.width=image.&&
&&&&&ImgD.height=image.
&&&&&ImgD.alt=image.width+"×"+image.
调用格式:
&img&src="a.gif"&onload="javascript:DrawImage(this);"
用asp把doc转换成html
doc2html.vbs
'**********************************************************
'&&&&调用方法:doc2html&c:\doc2html&c:\doc2html
'&&&&调用方法:doc2html&-s&c:\doc2html\a.doc&c:\doc2html
'**********************************************************
Dim&Objword
Dim&Objdoc
Dim&Objfso
Dim&Strsource
Dim&Strtarget
Dim&Bbatch
'得到命令行参数,有三种可能的格式:[-s]&要进行转换的源文件目录或文件&转换成Html文件后保存的目录
Function&Getparams()
Dim&Objarg
&&&&&If&Wscript.Arguments.Count&&=&2&Then
&&&&&&&&&&If&&Wscript.Arguments.Item(0)&=&"-s"&Or&Wscript.Arguments.Item(0)&=&"-S"&Then
&&&&&&&&&&&&&&&Strsource&=&Wscript.Arguments.Item(1)
&&&&&&&&&&&&&&&Strtarget&=&Wscript.Arguments.Item(2)
&&&&&&&&&&&&&&&Bbatch&=&False
&&&&&&&&&&Else
&&&&&&&&&&&&&&&Strsource&=&Wscript.Arguments.Item(0)
&&&&&&&&&&&&&&&Strtarget&=&Wscript.Arguments.Item(1)
&&&&&&&&&&&&&&&Bbatch&=&True
&&&&&&&&&&End&If
&&&&&&&&&&Wscript.Quit(1)
&&&&&End&If
End&Function
Function&Batchprocessing()
Dim&Objfolder
Dim&Objfile
Dim&Strfilename
&&&&&Lpos&=&0
&&&&&Set&Objfolder&=&Objfso.Getfolder(Strsource)
&&&&&For&Each&Objfile&In&Objfolder.Files
&&&&&&&&&&Lpos&=&Instr(1,Mid(Objfile.Path,Len(Objfile.Path)&-&3,4),"Doc",1)
&&&&&&&&&&If&Lpos&&&0&Then
&&&&&&&&&&&&&&&Strfilename&=&Objfso.Getbasename(Objfile.Path)
&&&&&&&&&&&&&&&Wordinterface&Objfile.Path,Strfilename
&&&&&&&&&&End&If
End&Function
Function&Singleprocessing()
Dim&Objfile
&&&&&Set&Objfile&=&Objfso.Getfile(Strsource)
&&&&&Strfilename&=&Objfso.Getbasename(Objfile.Path)
&&&&&Wordinterface&Objfile.Path,Strfilename
End&Function
Function&Wordinterface(Strfilename,Formattedfilename)
&&&&&Objword.Documents.Open&Strfilename
&&&&&Set&Objdoc&=&Objword.Activedocument
&&&&&'Stop
&&&&&'set&The&Title&Of&The&Document&To&Match&The&Filename
&&&&&Objdoc.Builtindocumentproperties(1)&=&Formattedfilename
&&&&&'1&=&Wdpropertytitle&In&Vba
&&&&&Objdoc.Saveas&Strtarget&&&"\"&&&Formattedfilename&&&".htm",8
&&&&&'objdoc.Saveas&"C:\Doc2Html\"&&&Formattedfilename&&&".htm",8
&&&&&On&Error&Resume&Next
&&&&&Objdoc.Close
End&Function
Set&Objfso&=&Createobject("Scripting.FileSystemObject")
Set&Objword&=&Createobject("Word.Application")
Objword.Visible&=&False
Call&Getparams
If&Bbatch&Then
&&&&&Call&Batchprocessing
&&&&&Call&Singleprocessing
Objword.Quit
Set&Objword&=&Nothing
都是精华啊!建议新人多来看看。
i'll&go&home&see&you&later.
1.自己写的将小写金额换成大写
'****人民币大小写转换格式****
dim&str(9)
str(0)="零"
str(1)="壹"
str(2)="贰"
str(3)="叁"
str(4)="肆"
str(5)="伍"
str(6)="陆"
str(7)="柒"
str(8)="捌"
str(9)="玖"
aa=Request.form("source")
hh=formatnumber(aa,2,-1)
aa=replace(hh,".","")
aa=replace(aa,",","")
for&i=1&to&len(aa)
s=mid(aa,i,1)
mynum=str(s)
select&case(len(aa)+1-i)
case&1:&k=&mynum&"分"
case&2:&k=&mynum&"角"
case&3:&k=&mynum&"元"
case&4:&k=&mynum&"拾"
case&5:&k=&mynum&"佰"
case&6:&k=&mynum&"仟"
case&7:&k=&mynum&"万"
case&8:&k=&mynum&"拾"
case&9:&k=&mynum&"佰"
case&10:&k=&mynum&"仟"
end&select
&title&数字转换&/title&
&meta&http-equiv="Content-Type"&content="text/&charset=gb2312"&
Elseif(s=".")&then
for&j=i&to&len(aa)
s=mid(aa,i,1)
mynum=str(s)
select&case(len(aa)+1-i)
case&1:&p=&mynum&"分"
case&2:&p=&mynum&"角"
end&select
&body&bgcolor="#FFFFFF"&
&form&method="post"&name="forma"&
&input&type="text"&name="source"&value="&%=hh%&"&
&input&type="text"&name="result"&value="&%=m%&"&size="40"&
&input&type="submit"&name="Submit"&value="提交&"&&
'获取中文字符串拼音首字母串的函数
response.write&"&link&href=style.css&rel=stylesheet&"
if&request.form("content")=""&then
response.write&"&center&&form&method=post&action=""""&&input&name=content&type=text&__&input&type=submit&&/form&"
function&getpychar(char)
tmp=65536+asc(char)
if(tmp&=45217&and&tmp&=45252)&then&
getpychar=&"A"
elseif(tmp&=45253&and&tmp&=45760)&then
getpychar=&"B"
elseif(tmp&=45761&and&tmp&=46317)&then
getpychar=&"C"
elseif(tmp&=46318&and&tmp&=46825)&then
getpychar=&"D"
elseif(tmp&=46826&and&tmp&=47009)&then&
getpychar=&"E"
elseif(tmp&=47010&and&tmp&=47296)&then&
getpychar=&"F"
elseif(tmp&=47297&and&tmp&=47613)&then&
getpychar=&"G"
elseif(tmp&=47614&and&tmp&=48118)&then
getpychar=&"H"
elseif(tmp&=48119&and&tmp&=49061)&then
getpychar=&"J"
elseif(tmp&=49062&and&tmp&=49323)&then&
getpychar=&"K"
elseif(tmp&=49324&and&tmp&=49895)&then&
getpychar=&"L"
elseif(tmp&=49896&and&tmp&=50370)&then&
getpychar=&"M"
elseif(tmp&=50371&and&tmp&=50613)&then&
getpychar=&"N"
elseif(tmp&=50614&and&tmp&=50621)&then&
getpychar=&"O"
elseif(tmp&=50622&and&tmp&=50905)&then
getpychar=&"P"
elseif(tmp&=50906&and&tmp&=51386)&then&
getpychar=&"Q"
elseif(tmp&=51387&and&tmp&=51445)&then&
getpychar=&"R"
elseif(tmp&=51446&and&tmp&=52217)&then&
getpychar=&"S"
elseif(tmp&=52218&and&tmp&=52697)&then&
getpychar=&"T"
elseif(tmp&=52698&and&tmp&=52979)&then&
getpychar=&"W"
elseif(tmp&=52980&and&tmp&=53640)&then&
getpychar=&"X"
elseif(tmp&=53689&and&tmp&=54480)&then&
getpychar=&"Y"
elseif(tmp&=54481&and&tmp&=62289)&then
getpychar=&"Z"
else&'如果不是中文,则不处理
getpychar=char
end&function
function&getpy(str)
for&i=1&to&len(str)
getpy=getpy&getpychar(mid(str,i,1))
end&function
content=request.form("content")
response.write&"&center&"&getpy(content)&chr(10)
response.write&"&br&&br&&br&&a&href=#&onclick=javascript:history.go(-1)&返回&/a&"
--------------------------------------------
ip限制函数
'******************************
'Function&CheckIp(cInput_Ip,cBound_Ip)
'Created&by&qqdao,&&
'说明:首先需要根据;号循环,然后判断是否含有"-",如果有则进行拆分处理,最后判断是否在范围内
'参数:&cInput_Ip,代检查的ip
'&cBound_Ip,给定的范围格式为,单个ip,和范围ip,范围ip最后使用”-“分割,如果是“*”则必须放到最后一位
'&&&&&&&&&&&&&&&&每个范围后添加":ALLOW"表示允许登陆,添加":REFUSE"表示拒绝登陆。多个范围用”;“隔开
'&&&&&&&&&&&&&&&&&例如192.168.1*.*:ALLOW;192.168.1.1:ALLOW;192.168.1.1-10:REFUSE"
'返回值:&true/false
'更新:&&支持ALLOW,REFUSE支持’*‘,不想对?支持,因为和*差不多
'******************************
function&CheckIp(cInput_Ip,cBound_Ip)
dim&cSingle_Ip,cTemp_IP,cStart_IP,cEnd_Ip
CheckIp&=&false
cSingle_Ip=split(cBound_Ip,";")&
&&&&&&&&for&i=0&to&ubound(cSingle_Ip)
&&&&&&&&&&&&if&Instr(cSingle_Ip(i),"REFUSE")&&&&0&then&&&&'就是拒绝了
&&&&&&&&&&&&&&&&&cTemp_IP&=&left(cSingle_Ip(i),instr(cSingle_Ip(i),":")-1)
&&&&&&&&&&&
&&&&&&if&Instr(cTemp_IP,"*")&&&&0&then&&'是宽范围
&&&&&&&&&&cStart_IP&=&left(cTemp_IP,instr(cTemp_IP,"*")-1)
&&&&&&&&&&if&left(cInput_Ip,len(cStart_IP))=cStart_IP&then
&&&&&&&&&&&CheckIp&=&false
&&&&&&&&&&&exit&function
&&&&&&&&&&end&if
&&&&&&&&&&&&&end&if
&&&&&&if&Instr(cTemp_IP,"-")&=&0&then
&&&cStart_IP&=&cTemp_IP
&&&cEnd_Ip&&&=&cTemp_IP
&&&&&&else
&&&cStart_IP&=&left(cTemp_IP,instr(cTemp_IP,"-")-1)
&&&cEnd_Ip&&&=&left(cStart_IP,InStrRev(cStart_IP,".")-1)+"."+mid(cTemp_IP,instr(cTemp_IP,"-")+1)
&&&&&&end&if
&&&&&&if&&Ip2Str(cInput_Ip)&=Ip2Str(cStart_IP)&and&Ip2Str(cInput_Ip)&=Ip2Str(cEnd_Ip)&then
&&&&&&&&&&CheckIp&=&false
&&&&&&&&&&exit&function
&&&&&&end&if
&&&&&elseif&Instr(cSingle_Ip(i),"ALLOW")&&&&0&then&&&&'允许
&&&&&&&&&&&
&&&&&&&&&&&&&&&&&cTemp_IP&=&left(cSingle_Ip(i),instr(cSingle_Ip(i),":")-1)
&&&&&&&&&&
&&&&&&if&Instr(cTemp_IP,"*")&&&&0&then&&&&&&&&&&'是宽范围
&&&&&&&&&&cStart_IP&=&left(cTemp_IP,instr(cTemp_IP,"*")-1)
&&&&&&&&&&if&left(cInput_Ip,len(cStart_IP))=cStart_IP&then
&&&&&&&&&&&CheckIp&=&true
&&&&&&&&&&end&if
&&&&&&&&&&&&&end&if
&&&&&&if&Instr(cTemp_IP,"-")&=&0&then
&&&cStart_IP&=&cTemp_IP
&&&cEnd_Ip&&&=&cTemp_IP
&&&&&&else
&&&cStart_IP&=&left(cTemp_IP,instr(cTemp_IP,"-")-1)
&&&cEnd_Ip&&&=&left(cStart_IP,InStrRev(cStart_IP,".")-1)+"."+mid(cTemp_IP,instr(cTemp_IP,"-")+1)
&&&&&&end&if
&&&&&&if&&Ip2Str(cInput_Ip)&=Ip2Str(cStart_IP)&and&Ip2Str(cInput_Ip)&=Ip2Str(cEnd_Ip)&then
&&&&&&&&&&CheckIp&=true
&&&&&&else
&&&&&&&&&&CheckIp&=false
&&&&&&end&if
&&&&&end&if
&&&&&&&next
end&function
挖到宝贝了
取当前网页的地址全名,以便返回用
Function&GetUrl()
&&On&Error&Resume&Next
&&Dim&strTemp
If&LCase(Request.ServerVariables("HTTPS"))&=&"off"&Then
strTemp&=&"http://"
strTemp&=&"https://"
&&strTemp&=&strTemp&&&Request.ServerVariables("SERVER_NAME")
&&If&Request.ServerVariables("SERVER_PORT")&&&&80&Then&strTemp&=&strTemp&&&":"&&&Request.ServerVariables("SERVER_PORT")
&&strTemp&=&strTemp&&&Request.ServerVariables("URL")
&&If&Trim(Request.QueryString)&&&&""&Then&strTemp&=&strTemp&&&"?"&&&Trim(Request.QueryString)
&&GetUrl&=&strTemp
End&Function
'Response.write&GetUrl()
url1=GetUrl()
url1=Server.URLEncode(url1)
上传文件时,显示进度条程序
在需要引用进度条的也面上用
&script&language="javascript"&src="../ShowProcessBar.js"&&/script&
&input&type="submit"&value="开始上传"&name="B1"&IsShowProcessBar="True"&&
传参数&true
ShowProcessBar.js
—————————————————————————————————————————
AddProcessbar();
var&bwidth=0;
var&swidth&=&document.all.waiting.clientW
function&CheckIsProcessBar(obj)
if&(obj.IsShowProcessBar=="True")&
function&CheckClick(e)
if&(e&==&1)
if&(bwidth&swidth*0.98){
bwidth&+=&(swidth&-&bwidth)&*&0.025;
if&(document.all)document.sbar.width&=&
else&document.rating.clip.width&=&
setTimeout('CheckClick(1);',1000);
if(document.all)
if(document.all.waiting.style.visibility&==&'visible')
{document.all.waiting.style.visibility&=&'hidden';
bwidth&=&1;}
whichIt&=&event.srcE
while&(CheckIsProcessBar(whichIt))
whichIt&=&whichIt.parentE
if&(whichIt&==&null)return&
document.all.waiting.style.pixelTop&=&(document.body.offsetHeight&-&document.all.waiting.clientHeight)&/&2&+&document.body.scrollT
document.all.waiting.style.pixelLeft&=&(document.body.offsetWidth&-&document.all.waiting.clientWidth)&/&2&+&document.body.scrollL
document.all.waiting.style.visibility&=&'visible';
if(!bwidth)CheckClick(1);
bwidth&=&1;
if(document.waiting.visibility&==&'show')
{document.waiting.visibility&=&'hide';
document.rating.visibility&=&'hide';
bwidth&=&1;}
if(e.target.href.toString()&!=&'')
document.waiting.top&=&(window.innerHeight&-&document.waiting.clip.height)&/&2&+&self.pageYO
document.waiting.left&=&(window.innerWidth&-&document.waiting.clip.width)&/&2&+&self.pageXO
document.waiting.visibility&=&'show';
document.rating.top&=&(window.innerHeight&-&document.waiting.clip.height)&/&2&+&self.pageYOffset+document.waiting.clip.height-10;
document.rating.left&=&(window.innerWidth&-&document.waiting.clip.width)&/&2&+&self.pageXO
document.rating.visibility&=&'show';
if(!bwidth)CheckClick(1);
bwidth&=&1;
function&AddProcessbar()
var&Str=""
Str+=&"&div&id=waiting&style=position:top:50left:100z-index:1;visibility:hidden&&";
Str+=&"&layer&name=waiting&visibility=visible&zIndex=2&&"
Str+=&"&table&border=2&cellspacing=1&cellpadding=0&bordercolorlight=#FFFFFF&bordercolordark=#C0C0C0&bgcolor=#E0E0E0&"
Str+=&"&&tr&"
Str+=&"&&td&bgcolor=#E0E0E0&height=30px&width=300px&align=center&"
Str+=&"&&font&color=black&数据正在处理中...&/font&"
Str+=&"&&/td&"
Str+=&"&&/tr&"
Str+=&"&&tr&"
Str+=&"&&td&bgcolor=#E0E0E0&"
Str+=&"&&img&width=1&height=10&name=sbar&style=background-color:#6699cc&"
Str+=&"&&/td&"
Str+=&"&&/tr&"
Str+=&"&/table&&"
Str+=&"&/layer&"
Str+=&"&/div&"
document.write(Str)
if(document.all)document.onclick&=&CheckC&
既然是常见问题,我也来几个。
控制滚动:
=============
&meta&http-equiv="Content-Type"&content="text/&charset=gb2312"&
&title&无标题文档&/title&
&body&style="margin:0px"&
&table&width="110"&border="0"&align="center"&cellpadding="2"&cellspacing="0"&height="300px"&
&&&&&td&id="i"&
&marquee&id="mar"&direction="up"&behavior="slide"&height="100px"&style="background-Color:#00ff00"&
&div&style="background-Color:#ff0000"&id="div"&
&&&&&&&p&&a&href="#"&分类一&/a&&/p&
&&&&&&&p&分类二&/p&
&&&&&&&p&分类三&/p&
&&&&&&&p&分类四&/p&
&&&&&&&p&分类五&/p&
&&&&&&&p&分类六&/p&
&&&&&/div&
&/marquee&
&div&id="div"&&/div&
&&&&&&&input&type="button"&name="btnUp"&value="向上"&onMouseOver="UpScroll();"&onMouseOut="StopScroll();"&
&&&&&&&input&name="btnDown"&type="button"&value="向下"&onMouseOver="DownScroll();"&onMouseOut="StopScroll();"&
&script&language="JavaScript"&
var&mar&=&document.all.
var&div&=&document.all.
var&h1&=&div.offsetH
var&h2&=&mar.
//向上移动
function&UpMarquee(){
if(mar.scrollTop&=h1)
StopScroll();
mar.scrollTop+=1;
function&DownMarquee(){
if(mar.scrollTop&=h2)
StopScroll();
mar.scrollTop-=1;
//alert(mar.scrollTop);
//循环调用向下移动函数
function&UpScroll(){
//alert(mar.scrollTop);
//StopScroll();
timer&=&setInterval('UpMarquee()',50);//循环调用
//循环调用向上移动函数
function&DownScroll(){
//StopScroll();
timer&=&setInterval('DownMarquee()',50);//循环调用
//清除循环调用
function&StopScroll(){
clearInterval(timer);
=======================================================
检查时间:
================
&meta&http-equiv="Content-Type"&content="text/&charset=gb2312"&
&title&&/title&
&script&language="JavaScript"&
function&isValid(vlu)
var&tmp1&=&"";
var&i&=&0;
var&bool&=&
vlu&+=&":";
i&=&vlu.indexOf(":");
tmp&=&vlu.substr(0,i);
vlu&=&vlu.substr(i+1,vlu.length);
bool&=&isErr(tmp)&&&isErr1(tmp)&&&isErr2(tmp);
i&=&vlu.indexOf(":");
tmp&=&vlu.substr(0,i);
vlu&=&vlu.substr(i+1,vlu.length);
bool&&=&isErr(tmp)&&&isErr1(tmp)&&&isErr3(tmp);
i&=&vlu.indexOf(":");
tmp&=&vlu.substr(0,i);
vlu&=&vlu.substr(i+1,vlu.length);
bool&&=&isErr(tmp)&&&isErr1(tmp)&&&isErr3(tmp);
if(bool&==&true)
alert("ok.");
alert("The&time&is&incorrect.");
function&isErr(vlu)
var&bool&=&vlu.indexOf("-")&&=&0&?&false&:&
bool&&=&vlu.indexOf(".")&&=&0&?&false&:&
function&isErr1(vlu)
return&isNaN(parseInt(vlu))&?&false&:&
function&isErr2(vlu)
return&parseInt(vlu)&&&23&?&false&:&
function&isErr3(vlu)
return&parseInt(vlu)&&&59&?&false&:&
//isValid("25:59:00");
&input&name="txtTime"&type="text"&id="txtTime"&value="09:05:59"&
&input&type="button"&name="Submit"&value="°&&A&"&onClick="isValid(document.all.txtTime.value);"&
调用Css做颜色变换:
======================
&meta&http-equiv="Content-Type"&content="text/&charset=gb2312"&
&title&&IÞ±ê&I&&I&A&&&/title&
&style&type="text/css"&
background-color:&#FF0000;
background-color:&#0000FF;
background-color:&#FFFF00;
background-color:&#00FF00;
background-color:�
background-color:&#FFFFFF;
background-color:&#00FFFF;
background-color:&#FF00FF;
&script&language="javascript"&
var&arrColor&=&new&Array("red","green","yellow","blue","black","white","cyan","purple");
var&index1&=&0;
var&index2&=&7;
function&ChangeColor1()
for(var&i=0;&i&8;&i++)
if(index1&==&8)&index1&=&0;
document.all('t'+(i+1)).className&=&arrColor[index1];
document.all('b'+(i+1)).innerText&=&document.all('t'+(i+1)).classN
document.all('b'+(i+1)).style.color&=&arrColor[index1++];
if(index1&==&8)&index1&=&0;
function&ChangeColor2()
for(var&i=8;&i&0;&i--)
if(index2&==&0)&index2&=&8;
document.all('c'+i).className&=&arrColor[--index2];
document.all('f'+i).innerText&=&document.all('c'+i).classN
document.all('f'+i).style.color&=&arrColor[index2];
if(index2&==&0)&index2&=&8;
&body&onLoad="setInterval('ChangeColor1()',500);setInterval('ChangeColor2()',500);"&
&table&width="720"&border="1"&align="center"&cellpadding="0"&cellspacing="0"&
&&&colgroup&
&& &col&width="12.5%"&
&col&width="12.5%"&
&col&width="12.5%"&
&col&width="12.5%"&
&col&width="12.5%"&
&col&width="12.5%"&
&col&width="12.5%"&
&col&width="12.5%"&
&&&/colgroup&
&&&&&td&id="t1"&class="red"&height="30"&&&/td&
&&&&&td&id="t2"&class="green"&&&/td&
&&&&&td&id="t3"&class="yellow"&&&/td&
&&&&&td&id="t4"&class="blue"&&&/td&
&&&&&td&id="t5"&class="black"&&&/td&
&&&&&td&id="t6"&class="white"&&&/td&
&&&&&td&id="t7"&class="cyan"&&&/td&
&&&&&td&id="t8"&class="purple"&&&/td&
&&&tr&style="font-size:10px"&align="center"&
&&&&&td&id="b1"&height="30"&&&/td&
&&&&&td&id="b2"&&&/td&
&&&&&td&id="b3"&&&/td&
&&&&&td&id="b4"&&&/td&
&&&&&td&id="b5"&&&/td&
&&&&&td&id="b6"&&&/td&
&&&&&td&id="b7"&&&/td&
&&&&&td&id="b8"&&&/td&
&& &td&colspan="8"&height="100"&&&/td&
&&&&&td&id="c1"&class="red"&height="30"&&&/td&
&&&&&td&id="c2"&class="green"&&&/td&
&&&&&td&id="c3"&class="yellow"&&&/td&
&&&&&td&id="c4"&class="blue"&&&/td&
&&&&&td&id="c5"&class="black"&&&/td&
&&&&&td&id="c6"&class="white"&&&/td&
&&&&&td&id="c7"&class="cyan"&&&/td&
&&&&&td&id="c8"&class="purple"&&&/td&
&&&tr&style="font-size:10px"&align="center"&
&&&&&td&id="f1"&height="30"&&&/td&
&&&&&td&id="f2"&&&/td&
&&&&&td&id="f3"&&&/td&
&&&&&td&id="f4"&&&/td&
&&&&&td&id="f5"&&&/td&
&&&&&td&id="f6"&&&/td&
&&&&&td&id="f7"&&&/td&
&&&&&td&id="f8"&&&/td&
见识了,呵呵强。
ASP中怎么运行一个服务器端程序呢
Set&WShShell&=&Server.CreateObject("WScript.Shell")&
RetCode&=&WShShell.Run("d:\xxx.exe",&1,&True)
'-----------------------------------------------------------
'功能:&过虑HTML字符
'输入:字符串
'输出:经格式化后的字符串
function&HTMLEncode(fString)
if&not&isnull(fString)&then
&&&&fString&=&replace(fString,&"&",&"&")
&&&&fString&=&replace(fString,&"&",&"&")
&&&&fString&=&Replace(fString,&CHR(32)&CHR(32),&"&&")
&&&&fString&=&Replace(fString,&CHR(9),&"&")
&&&&fString&=&Replace(fString,&CHR(34),&"&")
&&&&fString&=&Replace(fString,&CHR(39),&"'")
&&&&fString&=&Replace(fString,&CHR(13),&"")
&&&&fString&=&Replace(fString,&CHR(10)&&&CHR(10),&"&/P&&P&&")
&&&&fString&=&Replace(fString,&CHR(10),&"&BR&&")
&&&&HTMLEncode&=&fString
end&function
'参数:系统(如:product,article),条件(如果是数值,则默认为categoryID的值),排序,
'每页显示记录数,模式(more:显示更多字样,page:显示翻页导航),
'翻页导航模式(number:显示数字,page:显示上一页,下一页),记录显示模版名(显示记录的过程名)
class&List
dim&p_system '系统表,如tblProduct,tblArticle
dim&p_where '条件
& dim&p_orderBy '排序
dim&p_recordCount '每页显示记录数
&& dim&p_horizontal '每行显示记录数
&& dim&p_mode '列表模式,参数:more(更多模式,显示更多字样),page(列表模式,显示翻页导航)
&& dim&p_moreURL '更多模式时的URL
dim&p_paginationMode '翻页导航模式,参数:number(数字导航,显示如:1,2,3,4),page(翻页导航,显示如:上一页,下一页)
&& dim&p_models '列表模版过程
&& dim&p_table '列表的table标签
&& dim&p_page '页码
&&&&dim&p_member '是否显示会员产品
dim&p_groupWhere
& Private&Sub&Class_Initialize&
&&&& p_system=""
p_where=""
p_orderBy="&order&by&categoryID,orderBy,postdate"
p_recordCount=15
p_horizontal=4
p_moreURL=""
p_paginationMode="page"
p_models=""
p_table="&table&width=100%&border=0&align=center&cellpadding=0&cellspacing=0&bordercolor=#CCCCCC&&style='border-collapse:&collapse'&"
p_member=false
p_groupWhere="groupID=0"
&& Property&Let&system(value)
p_system=value
end&property
&& Property&Let&where(value)
if&isInt(value)&then
p_where="&where&categoryID="&value
p_where="&where&("&value&")"
end&property
&& Property&Let&orderBy(value)
p_orderBy="&order&by&"&value
end&property
&& Property&Let&recordCount(value)
p_recordCount=value
end&property
&& Property&Let&horizontal(value)
p_horizontal=value
end&property
&& Property&Let&mode(value)
p_mode=value
end&property
&& Property&Let&moreURL(value)
p_moreURL=value
end&property
&& Property&Let&paginationMode(value)
p_paginationMode=value
end&property
&& Property&Let&models(value)
p_models=value
end&property
&& Property&Let&table(value)
p_table=value
end&property
&& Property&Let&page(value)
if&getNumeric(value)&1&then
p_page=int(value)
end&property
&& Property&Let&member(value)
p_member=value
if&p_member&then
authorizationID=getValue("tblMember","authorizationID","memberID="&session("memberID"))
if&authorizationID=""&or&authorizationID=0&then
authorizationID=getValue("tblGroup","authorizationID","groupID="&session("groupID"))
virtual=getValue("tblAuthorization","virtual","authorizationID="&authorizationID)
authArr=split(virtual,",")
for&i=0&to&ubound(authArr)
if&i=0&then
p_groupWhere="groupID="&getValue("tblGroup","groupID","authorizationID="&authArr(i))
p_groupWhere=p_groupWhere&"&or&groupID="&getValue("tblGroup","groupID","authorizationID="&authArr(i))
p_groupWhere="groupID=0"
end&property
public&sub&List()
if&p_where=""&then
where="&where&"&p_groupWhere&"&and&publish=1"
where=p_where&"&and&("&p_groupWhere&")&and&publish=1"
strSql="select&*&from&"&p_system&where&p_orderBy
'response.write&strSql
'response.end
set&rs=getRecord(strSql)
if&rs.eof&then
response.write&convertEncode(lgeNoRecord,gb,language)
rs.pageSize=p_recordCount
if&rs.pagecount&p_page&then&p_page=rs.pagecount
rs.AbsolutePage=p_page
response.write&p_table
for&i=1&to&p_recordCount
if&rs.eof&then
response.write&"&tr&"
for&ih=0&to&p_horizontal
if&ii=p_recordCount&then
if&rs.eof&then
response.write&"&td&width="&&&1/(p_horizontal+1)*100&&&"%&&&&/td&"
response.write&"&td&width="&&&1/(p_horizontal+1)*100&&&"%&&"
execute&"call&"&&&p_models
response.write&"&/td&"
rs.movenext
response.write&"&/tr&"
response.write&"&/table&"
if&p_mode="more"&then
response.write&"&div&align=right&"&p_moreURL&"&/div&"
if&p_mode="page"&then
response.write&"&table&width=100%&border=0&cellspacing=0&cellpadding=3&&tr&&td&align=right&"
call&pagination(p_page,rs.recordCount,rs.pageCount,p_paginationMode)
response.write&"&/td&&/tr&&/table&"
'-------------------------------列表过程结束-------------------------------------------------------------
精華,建義寫一本書!呵呵!
当我第一次浏览该网页news.asp时可以。但我刷新一下出现下面的错误
-------------------------------------------
Microsoft&OLE&DB&Provider&for&ODBC&Drivers&错误&'80040e21'&
ODBC&驱动程序不支持所需的属性。&
/sql/news.asp,行5&
-----------------------------------------------------
我的conn.asp&是这样的。
set&conn&=server.CreateObject&("adodb.connection")
conn.Open&"driver={SQL&Server};server=(local);uid=password=2222;database=news"
该news.asp
&!--#include&file="conn.asp"&--&
set&rs=server.createobject("adodb.recordset")
sql="select&*&from&newsType&where&flag=1"
rs.open&sql,conn,1,1
&%=rs("typeid")%&
&%&rs.close
set&rs=nothing
然后我在conn.asp的文件里加了这句话&%on&error&resume&next%&‘就可以了。
&!--#include&file="conn.asp"&--&
&%on&error&resume&next%&‘就是这句话'
set&rs=server.createobject("adodb.recordset")
sql="select&*&from&newsType&where&flag=1"
rs.open&sql,conn,1,1
&%=rs("typeid")%&
&%&rs.close
set&rs=nothing%&
该news.asp
&!--#include&file="conn.asp"&--&
&%on&error&resume&next%&‘这句话"
set&rs=server.createobject("adodb.recordset")
sql="select&*&from&newsType&where&flag=1"
rs.open&sql,conn,1,1
&%=rs("typeid")%&
&%&rs.close
set&rs=nothing
什么呢???这不知是不是个问题
好东东。。。再接再历
http://expert.csdn.net/Expert/topic/.xml?temp=.9789087
屏蔽后退键:
http://expert.csdn.net/Expert/topic/.xml?temp=.4249231
生成XML文件:
http://search.csdn.net/expert/topic/3/306//649096.htm
如果有时间,整理成CHM供下载更好,:_)
ftp://qxlq.vicp.net:21001/
我常用的编程参考CHM书,哪位找个公共空间放放,我自己的机器不稳定
二十八条改善&ASP&性能和外观的技巧&
/china/technet/iis/tips/ASPTIPS.asp
如何在客户端无刷新调用服务端代码
1.&iframe&src="ifm.asp?param=??"&&/iframe&
2.xmlhttp:
dim&&objXMLHTTP
set&&objXMLHTTP=CreateObject("MICROSOFT.XMLHTTP")&&
objXMLHTTP.open&&"GET","xmlhttp.asp",false
&'参数1:post,get;参数2:请求的URL,&参数3:同步或异步调用
objXMLHTTP.send&&""
magbox&objXMLHTTP.ResponseText&&'服务端输出到客户端的文本数据
------------
xmlhttp:参考
/library/default.asp?url=/library/en-us/xmlsdk30/htm/xmobjxmlhttprequest.asp
谁能把这些全整理成chm呢????
'取得地址栏完整地址
Function&GetUrl()
&&On&Error&Resume&Next
&&Dim&strTemp
If&LCase(Request.ServerVariables("HTTPS"))&=&"off"&Then
strTemp&=&"http://"
strTemp&=&"https://"
&&strTemp&=&strTemp&&&Request.ServerVariables("SERVER_NAME")
&&If&Request.ServerVariables("SERVER_PORT")&&&&80&Then&strTemp&=&strTemp&&&":"&&&Request.ServerVariables("SERVER_PORT")
&&strTemp&=&strTemp&&&Request.ServerVariables("URL")
&&strtemp=left(strtemp,instrRev(strtemp,"/"))
&&GetUrl&=&strTemp
End&Function
Response.write&GetUrl()
'===========================================================
'分页类,大体思想由.Net的DataGrid的使用方式而来
'功能:自动生成datagrid列表头和内容,以及分页栏
'根据网友bubuy&(澎湃&NoMoneyToBuy)得分页函数修改成类
'使用示例:
'dim&Fld(2)
'dim&FldName(2)
'dim&FldWidth(2)
'Fld(0)&=&"ID"
'Fld(1)&=&"Title"
'Fld(2)&=&"Input_Date"
'FldName(0)&=&"编号"
'FldName(1)&=&"标题"
'FldName(2)&=&"录入日期"
'FldWidth(0)&=&"10%"
'FldWidth(1)&=&"60%"
'FldWidth(2)&=&"30%"
'set&DG&=&new&DataGrid
'DG.DataSource&=&rs_Grid
'DG.titleColor&=&"#DCE19D"
'DG.PageSize&=&1
'DG.Fields&=&Fld
'DG.FieldsName&=&FldName
'DG.fieldWidth&=&FldWidth
'Url&=&request.ServerVariables("URL")&&&"?Param=testParameter"&'存在原有参数的情况
'DG.Url&=&Url
'DG.Generate()
'=============Designed&By&windancer&===============
Class&DataGrid
&&Private&obj_RecordSet & '&recordset
&&Private&int_PageSize
'&每页纪录数
&&'两个数组保存数据库字段名和中文名称
&&Private&Arr_Field
'&数据库字段
&&Private&Arr_FieldName
'&字段显示名称()
&&Private&Arr_FieldWidth '&字段显示宽度
&&Private&str_TitleColor '&表头颜色#efffce
&&Private&str_Url
'请求的URL
&&Private&str_Error&&&&&&&&'&出错信息
&&Private&Sub&Class_Initialize()
&&int_PageSize&=&10
&&str_TitleColor&=&"#ffffff"
&&str_Error&=&""
'===============================================================
'================================================================
'-----------------------------------
'数据源,暂时只支持RecordSet
'-----------------------------------
&&Public&Property&Let&dataSource(obj)
&&&&set&obj_RecordSet&=&obj
&&End&Property
&&Public&Property&Let&pageSize(intValue)
&&&&int_PageSize&=&intValue
&&End&Property
&&Public&Property&Get&pageSize
&&&&PageSize=&int_Categoryid
&&End&Property
&&Public&Property&Let&Fields(Arr)
&&&&Arr_Field&=&Arr
&&End&Property
&&Public&Property&Get&Fields
&&&&Fields=&Arr_Field
&&End&Property
&&Public&Property&Let&fieldsName(Arr)
&&&&Arr_FieldName&=&Arr
&&End&Property
&&Public&Property&Get&fieldsName
&&&&fieldsName=&Arr_FieldName
&&End&Property
&&Public&Property&Let&fieldWidth(Arr)
&&&&Arr_FieldWidth&=&Arr
&&End&Property
&&Public&Property&Get&fieldWidth
&&&&fieldWidth=&Arr_FieldWidth
&&End&Property
&&Public&Property&Let&titleColor(strValue)
&&&&str_TitleColor&=&strValue
&&End&Property
&&Public&Property&Get&titleColor
&&&&titleColor=&str_TitleColor
&&End&Property
&&'-----------------------------------------------------
&&'这个属性是为了保存Url路径
&&'如果当前路径带有参数,那么就用&Page=x,否则就用?Page=x
&&'------------------------------------------------------
&&Public&Property&Let&Url(StrValue)
&&&&str_Url&=&StrValue
&&End&Property
&&Public&Property&Get&Url
&&&&Url=&str_Url
&&End&Property
'================================================================
'================================================================
'----------------------------------------------------------------
'显示当前错误
'----------------------------------------------------------------
Private&Sub&ShowLastError()
response.Write(str_Error)
response.End()
'----------------------------------------------------------------
'Generate()
'利用ado分页
'-----------------------------------------------------------------
Public&Sub&Generate()
'----检查参数--------------------------
'---------变量声明-----------------------------------
Dim&FieldCount
FieldCount&=&Ubound(Arr_Field)&+&1
& Dim&CurrentPage
Dim&PgCount
Dim&RecCount
'记录数,本来用rs.recordCount可以取到,保存下来效率会比较高
Dim&HasOtherParam
'URL是否包含其他参数
Dim&PageParam
'当前分页Url参数
Dim&PageInfomation
'当前分页状态信息
Dim&Seperator
'设置分隔符
Seperator&=&"&&"
'-------------处理Url参数---------------------------
if&instr(str_Url,"?")&0&then
HasOtherParam&=&true
PageParam&=&"&Page="
HasOtherParam&=&false
PageParam&=&"?Page="
'----------获取当前页--------------------------------
CurrentPage&=&request.QueryString("Page")
if&CurrentPage=""&then
CurrentPage=1
CurrentPage=Cint(CurrentPage)
'-----------处理数据源------------------------------
obj_RecordSet.PageSize&=&int_PageSize
RecCount&=&obj_RecordSet.RecordCount
PgCount&=&obj_RecordSet.PageCount
IF&obj_RecordSet.Eof&Then
Response.Write("&center&&font&stlye='font-size:14'&color='#ff0000'&对不起,没有记录!&/font&&/center&")
'-----------处理ADO分页----------------------------
IF&CurrentPage&&&1&Then&
CurrentPage&=&1
If&CurrentPage&PgCount&Then
CurrentPage&=&PgCount
obj_RecordSet.absolutepage&=&CurrentPage
Response.Write("&table&width=100%&border='0'&cellpadding='0'&cellspacing='0'&style='font-size:12'&")&
'---------------翻页链接-----------------------------
Dim&FirstLink,PrevLink,NextLink,LastLink&'定义向上和向下翻的变量
'-----------------------首页-------------------------
if&CurrentPage&1&then
FirstLink&=&"&a&href='"&&&URL&&&PageParam&&&"1'&首页&/a&"
PrevLink&=&"&a&href='"&&&URL&&&PageParam&&&Cstr(CurrentPage-1)&&&"'&上一页&/a&"
FirstLink&=&"首页"
PrevLink&=&"上一页"
'------------下一页----------------
if&CurrentPage&PgCount&then
NextLink&=&"&a&href='"&&&URL&&&PageParam&&&Cstr(CurrentPage+1)&&&"'&下一页&/a&"
LastLink&=&"&a&href='"&&&URL&&&PageParam&&&PgCount&&&"'&尾页&/a&"
NextLink&=&"下一页"
LastLink&=&"尾页"
PageInfomation&=&FirstLink&&&Seperator&&&PrevLink&&&Seperator&&&NextLink&&&Seperator&&&LastLink&&&Seperator&&&"每页"&&&Cstr(int_PageSize)&&&"条记录"&&&Seperator&&&&"共"&&&PgCount&&&"页"&&&Seperator&&&"目前第"&&&CurrentPage&&&"页"&&&Seperator
Response.Write("&tr&&td&align=center&")
Response.Write("&table&width='100%'&border='1'&cellpadding='2'&cellspacing='2'&bordercolor='#999999'&")
'---------------设置表头-----------------
Response.Write("&tr&bgcolor='"&&&str_TitleColor&&&"'&")
For&i=0&to&FieldCount&-1
Response.Write("&td&align='center'&width='"&&&Arr_FieldWidth(i)&&&"'&&font&style='font-size:14'&&b&"&&&Arr_FieldName(i)&&&"&/b&&/font&&/td&")
Response.Write("&/tr&")
'---------------------输出内容---------------------------------
While&(not&obj_RecordSet.EOF)&and&i&int_PageSize
Dim&Cursor
Response.Write("&tr&")
For&Cursor&=&0&to&FieldCount&-1
&&&Response.Write("&td&align='center'&"&&&obj_RecordSet(Arr_Field(Cursor))&&&"&/td&")
Response.Write("&/tr&")
obj_RecordSet.MoveNext
'------------------------输出分页条------------------------------------
Response.Write("&tr&&td&align='right'&colspan='"&&&Cstr(FieldCount)&&&"'&"&&&PageInfomation&&&"&/td&&/tr&")
response.Write("&/table&&/td&&/tr&&/table&")
'----------检查参数是否正确---------------
Private&Sub&Check()
if&Ubound(Arr_Field)&&Ubound(Arr_FieldName)&then
str_Error="Fields数组和FieldName数组维数必须相同"
if&obj_RecordSet=empty&then
str_Error="数据源不能为空,请设置dataSource属性"
if&int_PageSize=""&then
str_Error="数据源不能为空"
ShowLastError
顶一下!!
防止用户直接访问页面(防止自制表单提交,直接通过链接访问)
function&checkPrePage()
url=request.ServerVariables("HTTP_REFERER")
url=trim(replace(url,"http://",""))
url=trim(left(url,len(request.ServerVariables("SERVER_NAME"))))
if&url&&trim(request.ServerVariables("server_name"))&then
response.Write("请通过正当的方法访问本网站")
response.End()
end&function
通过一下的两个函数可以实现图片,文字的同时提交处理。
Function&BinaryToString(str)
strto&=&""
for&i=1&to&lenb(str)
if&AscB(MidB(str,&i,&1))&&&127&then
strto&=&strto&&&chr(Ascb(MidB(str,&i,&1))*256+Ascb(MidB(str,&i+1,&1)))
strto&=&strto&&&Chr(AscB(MidB(str,&i,&1)))
BinaryToString=strto
End&Function
function&gainformdata(n)
dim&formsize,formdata,divider,datastart,dataend
redim&mydata(n-1)
formsize&=&Request.TotalBytes
formdata&=&Request.BinaryRead(formsize)
for&i=1&to&n
bncrlf&=&chrB(13)&&&chrB(10)
divider&=&leftB(formdata,clng(instrB(formdata,bncrlf))-1)
datastart&=&instrB(formdata,bncrlf&&&bncrlf)+4
dataend&=&instrB(datastart+1,formdata,divider)&-&datastart-2
mydata(i-1)&=&midB(formdata,datastart,dataend)
formdata=rightB(formdata,clng(formsize-instrB(datastart+1,formdata,divider))+1)
formsize=lenB(formdata)
gainformdata=mydata
end&function
&form&name="form1"&method="post"&action="b.asp"&&enctype="multipart/form-data"&
&&&textarea&name="txt"&&/textarea&
&&&input&type="file"&name="file"&
&&&input&type="submit"&name="Submit"&value="提交"&
'链接数据库
data=gainfromdata(2)
rs("txt")=binarytostring(data(0))
rs("img").appendchunk=data(1)
--更正,前面发的,字段少了一个type,特此补上:
'==================================================================--
用ASP实现无组件上传/下载文件
'&功能简介
'&将上传的文件数据保存到数据库中,可以处理表单中的多个上传文件的情况
'&适用于各种数据库,使用ADO的方法连接数据库
'&本示例中使用的是ACCESS数据库:zj.mdb
'&表:tb_img(id&int(自增列),path&text(255)&保存上传文件的目录
' ,fname&text(250)&保存上传的文件名,type&test(250)&保存上传文件的类型
'&&&&&&&&,img&ole对象&保存上传的文件内容
'&邹建&&2003.10
'==================================================================
'==================================================================
' 上传文件的HTML页:&zj_up.htm
'==================================================================
&title&文件上传保存到数据库中&/title&
&form&name="form1"&enctype="multipart/form-data"&method="post"&action="zj_up.asp"&
&&&&&input&type="file"&name="file"&
&&&&&input&type="submit"&name="Submit"&value="上传"&
'==================================================================
上传文件保存到数据库的ASP页:&zj_up.asp
'==================================================================
Response.Expires=0
Function&f_Bin2Str(ByVal&sBin)
&&&&Dim&iI,&iLen,&iChr,&iRe&&&&&&&
&&&&iRe&=&""
&&&&If&Not&IsNull(sBin)&Then
&&&&&&&&iLen&=&LenB(sBin)
&&&&&&&&For&iI&=&1&To&iLen
&&&&&&&&&&&&iChr&=&MidB(sBin,&iI,&1)
&&&&&&&&&&&&If&AscB(iChr)&&&127&Then
&&&&&&&&&&&&&&&&iRe&=&iRe&&&Chr(AscW(MidB(sBin,&iI&+&1,&1)&&&iChr))
&&&&&&&&&&&&&&&&iI&=&iI&+&1
&&&&&&&&&&&&Else
&&&&&&&&&&&&&&&&iRe&=&iRe&&&Chr(AscB(iChr))
&&&&&&&&&&&&End&If
&&&&&&&&Next
&&&&End&If&&&&
&&&&f_Bin2Str&=&iRe
End&Function
iConcStr&=&"Provider=Microsoft.Jet.OLEDB.4.0;Persist&Security&Info=False"&&&_&
";Data&Source="&&&server.mappath("zj.mdb")
iSql="tb_img"
set&iRe=Server.CreateObject("ADODB.Recordset")
iRe.Open&iSql,iConcStr,1,3
iLen=Request.TotalBytes
sBin=Request.BinaryRead(iLen)
iCrlf1&=&ChrB(13)&&&ChrB(10)
iCrlf2&=&iCrlf1&&&iCrlf1
iLen&=&InStrB(1,&sBin,&iCrlf1)&-&1
iSpc&=&LeftB(sBin,&iLen)
sBin&=&MidB(sBin,&iLen&+&34)
iPos1&=&InStrB(sBin,&iCrlf2)&-&1
While&iPos1&&&0
iStr&=&f_Bin2Str(LeftB(sBin,&iPos1))
iPos1&=&iPos1&+&5
iPos2&=&InStrB(iPos1,&sBin,&iSpc)
iPos3&=&InStr(iStr,&";&filename=""")&+&12
If&iPos3&&&12&Then
iStr&=&Mid(iStr,&iPos3)
iPos3&=&InStr(iStr,&Chr(13)&&&Chr(10)&&&"Content-Type:&")&-&2
iFn&=&Left(iStr,&iPos3)
If&iFn&&&&""&Then
iRe.AddNew
ire("path")=left(iFn,instrrev(iFn,"\"))
iRe("fname")&=&mid(iFn,instrrev(iFn,"\")+1)
iRe("type")&=&Mid(iStr,&iPos3&+&18)
iRe("img").AppendChunk&MidB(sBin,&iPos1,&iPos2&-&iPos1)
iRe.Update
sBin&=&MidB(sBin,&iPos2&+&iLen&+&34)
iPos1&=&InStrB(sBin,&iCrlf2)&-&1
set&iRe=Nothing
'==================================================================
下载数据的ASP页:&zj_down.asp
'==================================================================
Response.Buffer=true
Response.Clear
iConcStr&=&"Provider=Microsoft.Jet.OLEDB.4.0;Persist&Security&Info=False"&&&_&
";Data&Source="&&&server.mappath("zj.mdb")
set&iRe=server.createobject("adodb.recordset")
iSql="tb_img"
iRe.open&iSql,iconcstr,1,1
Response.ContentType=ire("type")
Response.BinaryWrite&iRe("img")
set&iRe=Nothing
&&&弹出提示信息&,&确定&与&取消&怎么做的
&&&&onclick="{if(confirm('确定删除选定的纪录吗?')){this.document.inbox.submit();return&}return&}"
6.&&组合查询的优化,谢谢&
sql&=&"select&*&from&book&where&bname&like&'%"&&&txtbname.Text&&&"%'&and&bauthor&like&'%"&&&txtauthor.Text&&&"%'&and&bpublish&like&'%"&&&txtpublish.Text&&&"%'&and&bdescription&like&'%"&&&txtdescription.Text&&&"%'&order&by&bookid&desc"
组合查询,有是四个组合条件,这样写是不是效率比较低,我该怎么优化一下呢?
分析,在SQL中,用LIKE是比较费时间的,所以最好是少用。
同时 ,四个TEXT框,输入条件是,一定会有没有输入的条件的时候,就会出现&LIKE&"%"的情况,其实这种情况下就等于这个条件没有。
所以,把生成SQL语句的代码多写些,
Dim&WhereStr&as&string
if&txtbname.Text&&""&then&
&&&&WhereStr="bname&like&'%"&&&txtbname.Text&&&"%'"
ELSE&IF&....
这样是一个概率的问题,如果四个全输入的话,是一样的,但如果只输入一个的问,速度会比你的快些!
&sql&=&"select&*&from&book&where&"
If&txtbname.Text&&&&""&Then
&&&sql&=&sql&&&"bname&like&'%"&&&txtbname.Text&&&"%'"
ElseIf&txtauthor.Text&&&&""&Then
&&&sql&=&sql&&&"bauthor&like&'%"&&&txtauthor.Text&&&"%'"
ElseIf&txtpublish.Text&&&&""&Then
&&&sql&=&sql&&&"bpublish&like&'%"&&&txtpublish.Text&&&"%'"
ElseIf&txtdescription.Text&&&&""&Then
&&&sql&=&sql&&&"bdescription&like&'%"&&&txtdescription.Text&&&"%'&&"
8.如何禁止刷新
&SCRIPT&LANGUAGE="JavaScript"&
document.onkeydown&=&function()&{
if(event.keyCode==116)&{
event.keyCode=0;
event.returnValue&=&
document.oncontextmenu&=&function()&{event.returnValue&=&}
页面已经禁止刷新
sql&server&用:sql&=&"update&reg&set&dealtime=getdate()&where&id=&"&&&request.querystring("id")
因为&SQL&SERVER里没有&now()&这个函数,而是用&getdate()&取代了
所以你的会报错.
ACCESS没有这个函数:)
只有date()和now()
ASP操纵SerV-U开FTP
http://expert.csdn.net/Expert/topic/.xml?temp=1.
连结其他数据库的方法(*.dbf,*.txt,excel,foxpro等)&&&&----收藏
&18:41:05&&&浏览次数:145&&
'连结dbf文件&
'&&建立Connection&&对象&
Set&&conn&&=&&Server.CreateObject("ADODB.Connection")&
Driver&&=&&"Driver={Microsoft&&Visual&&FoxPro&&Driver};"&
SourceType&&=&&"SourceType=DBF;"&
DBPath&&=&&"SourceDB="&&&&&Server.MapPath(&&"Dbf"&&)&
'&&调用Open&&方法连接数据库&
conn.Open&&Driver&&&&&SourceType&&&&&DBPath&
Set&&rs&&=&&Server.CreateObject("ADODB.Recordset")&
'&&打开数据源,参数二为Connection对象&
rs.Open&&"Select&&*&&From&&sample",&&conn,&&2,&&2&
'连结foxpro文件&
'&&建立Connection&&对象&
Set&&conn&&=&&Server.CreateObject("ADODB.Connection")&
Driver&&=&&"Driver={Microsoft&&Visual&&FoxPro&&Driver};"&
SourceType&&=&&"SourceType=DBC;"&
DBPath&&=&&"SourceDB="&&&&&Server.MapPath(&&"Dbf/Sample.dbc"&&)&
'&&调用Open&&方法连接数据库&
conn.Open&&Driver&&&&&SourceType&&&&&DBPath&
Set&&rs&&=&&Server.CreateObject("ADODB.Recordset")&
'&&打开数据源,参数二为Connection?对象&
rs.Open&&"Select&&*&&From&&sample",&&conn,&&2,&&2&
'连结excel文件&
'&&建立Connection对象&
Set&&conn&&=&&Server.CreateObject("ADODB.Connection")&
Driver&&=&&"Driver={Microsoft&&Excel&&Driver&&(*.xls)};"&
DBPath&&=&&"DBQ="&&&&&Server.MapPath(&&"Sample.xls"&&)&
'&&调用Open&&方法连接数据库&
conn.Open&&Driver&&&&&DBPath&
Set&&rs&&=&&Server.CreateObject("ADODB.Recordset")&
'&&打开数据源,参数二为Connection对象&
rs.Open&&"Select&&*&&From&&[成绩单$]",&&conn,&&2,&&2&
'连结txt文件&
'&&?建立Connection&&对象&
Set&&conn&&=&&Server.CreateObject("ADODB.Connection")&
Driver&&=&&"Driver={Microsoft&&Text&&Driver&&(*.&&*.csv)};"&
DBPath&&=&&"DBQ="&&&&&Server.MapPath(&&"Text"&&)&
'&&调用Open&&方法连接数据库&
conn.Open&&Driver&&&&&DBPath&
Set&&rs&&=&&Server.CreateObject("ADODB.Recordset")&
'&&打开数据源,参数二为Connection?对象&
rs.Open&&"Select&&*&&From&&sample.txt",&&conn,&&2,&&2&
&OBJECT&id=StructuredGraphicsControl1&style="LEFT:&0&WIDTH:&392&TOP:&0&HEIGHT:&240px"&
&height=240&width=392&classid="clsid:-D7AC-11D0-89D5-00A0C90833E6"&&&
&SCRIPT&LANGUAGE=vbscript&
StructuredGraphicsControl1.DrawingSurface.ArcDegrees&0,0,0,30,50,60
StructuredGraphicsControl1.DrawingSurface.ArcRadians&30,0,0,30,50,60
StructuredGraphicsControl1.DrawingSurface.Line&10,10,100,100
&!--&#include&file=../inc/connect.asp&--&
&meta&http-equiv="Content-Type"&content="text/&charset=gb2312"&
&title&下载excel文件&/title&
set&rs=server.CreateObject("adodb.recordset")
sql=request("sql")
sql=replace(sql,"|百分号|",ucase("%"))
title=request("title")
'response.write&sql&&&"&br&"
rs.open&sql,conn,3,2
set&xlapp=server.createobject("excel.application")
xlapp.Visible&=&False
set&mybook=xlapp.Workbooks.Add
set&mysheet=mybook.worksheets(1)
myarray=split(title,"|")
for&i=0&to&ubound(myarray)-1
rangex=ucaSE(chr(65+i))
mysheet.range(rangex&&&1&).value=cstr(myarray(i))
set&myarray=nothing
if&rs.recordcount&0&then
do&while&not&&rs.eof
for&i=0&to&rs.fields.count-1
if&i&26&then
rangex=ucaSE(chr(65+i))
'response.write&rangex&&&j&&&&"&br&"
if&not&isnull(rs.fields(i).value)&then& &&mysheet.range(rangex&&&j&).value=cstr(rs.fields(i).value)
rs.movenext
'response.write&rs.fields.count&&&"&br&"
'response.write&rs.recordcount&&&"&br&"
myfilename=Session("UserRealName")&&&date()&&&"-"&&&cint(rnd&*10000)&&&".xls"
mypath=server.mappath("excel.asp")
myarray=split(mypath,"\")
for&i=0&to&ubound(myarray)-1
mypath=mypath&&&&myarray(i)&&&"\"
'response.write&mypath&&&myfilename
mybook.saveas(mypath&&&myfilename)
mybook.close
xlapp.quit
set&mysheet=nothing
set&mybook=nothing
set&xlapp=nothing
&img&src="../i/D_Wealth_Out.gif"&width="16"&height="16"&&a&name="download"&href="&%="download.asp?filename="&&&&myfilename%&"&下载
&%=myfilename%&&/a&
下载任何文件(尤其是IE关联打开的)
Dim&Stream
Dim&Contents
Dim&FileName
Dim&FileExt
Const&adTypeBinary&=&1
FileName&=&Request.QueryString("FileName")
if&FileName&=&""&Then
&&&&Response.Write&"无效文件名."
&&&&Response.End
'&下面是不希望下载的文件
FileExt&=&Mid(FileName,&InStrRev(FileName,&".")&+&1)
Select&Case&UCase(FileExt)
&&&&Case&"ASP",&"ASA",&"ASPX",&"ASAX",&"MDB"
&&&&&&&&Response.Write&"受保护文件,不能下载."
&&&&&&&&Response.End
End&Select
'&下载这个文件
Response.Clear
Response.ContentType&=&"application/octet-stream"
Response.AddHeader&"content-disposition",&"&filename="&&&FileName
Set&Stream&=&server.CreateObject("ADODB.Stream")
Stream.Type&=&adTypeBinary
Stream.Open
Stream.LoadFromFile&Server.MapPath(FileName)
While&Not&Stream.EOS
&&&&Response.BinaryWrite&Stream.Read(1024&*&64)
Stream.Close
Set&Stream&=&Nothing
Response.Flush
Response.End
asp常用函数
*************************************************
*blueice&2003整理&&&&&&&&&&*
*************************************************
asp常用函数&&
CreateObject()
DateDiff()
FormatCurrency()
FormatNumber()
FormatPercent()
InstrRev()
IsNumeric()
IsObject()
Month()&& 
MonthName()
StrReverse()&
UCase()&& 
VarType()& 
WeekDay()&
WeekDayName()&
_______________________________________________________________________________&
_______________________________________________________________________________
_______________________________________________________________________________
 FUNCTION:&返回一个数组&
 SYNTAX:&Array(list)&
 ARGUMENTS:&字符,数字均可&
 EXAMPLE:&&%
Dim&myArray()
For&i&=&1&to&7
 &Redim&Preserve&myArray(i)
 &myArray(i)&=&WeekdayName(i)
 RESULT:&建立了一个包含7个元素的数组myArray
myArray("Sunday","Monday",&...&...&"Saturday")&
_______________________________________________________________________________
 FUNCTION:&将一个表达式转化为数字类型&
 SYNTAX:&CInt(expression)&
 ARGUMENTS:&任何有效的字符均可&
 EXAMPLE:&&%
response.write&cINT(f)&+&2
 RESULT:&236
转化字符"234"为数字"234",如果字符串为空,则返回0值 &
_______________________________________________________________________________
CreateObject()&
 FUNCTION:&建立和返回一个已注册的ACTIVEX组件的实例。&
 SYNTAX:&CreateObject(objName)&
 ARGUMENTS:&objName&是任何一个有效、已注册的ACTIVEX组件的名字.&
 EXAMPLE:&&%
Set&con&=&Server.CreateObject("ADODB.Connection")
 RESULT: 
_______________________________________________________________________________
 FUNCTION:&转化一个表达式为字符串.&
 SYNTAX:&CStr(expression)&
 ARGUMENTS:&expression&是任何有效的表达式。&
 EXAMPLE:&&%
response.write&"The&result&is:&"&&&cStr(s)
 RESULT:&转化数字“5”为字符“5”。&
_______________________________________________________________________________
 FUNCTION:&返回当前系统日期.&
 SYNTAX:&Date()&
 ARGUMENTS:&None.&
 EXAMPLE:&&%=Date%&&
 RESULT:&8/4/99&
_______________________________________________________________________________
DateAdd()&
 FUNCTION:&返回一个被改变了的日期。&
 SYNTAX:&DateAdd(timeinterval,number,date)&
 ARGUMENTS:&timeinterval&is&the&time&interval&to&&number&is&amount&of&
time&intervals&to&&and&date&is&the&starting&date.&
 EXAMPLE:&&%
currentDate&=&#8/4/99#
newDate&=&DateAdd("m",3,currentDate)
response.write&newDate
currentDate&=&#12:34:45&PM#
newDate&=&DateAdd("h",3,currentDate)
response.write&newDate
 RESULT:&11/4/99
3:34:45&PM
"m"&=&"month";
"d"&=&"day";
If&currentDate&is&in&time&format&then,
"h"&=&"hour";&
"s"&=&"second";&
_______________________________________________________________________________
DateDiff()&
 FUNCTION:&返回两个日期之间的差值&。&
 SYNTAX:&DateDiff(timeinterval,date1,date2&[,&firstdayofweek&][,&
firstweekofyear]])&
 ARGUMENTS:&timeinterval&表示相隔时间的类型,如“M“表示“月”。&
 EXAMPLE:&&%
fromDate&=&#8/4/99#
toDate&=&#1/1/2000#
response.write&"There&are&"&&&_
 &DateDiff("d",fromDate,toDate)&&&_
 &"&days&to&millenium&from&8/4/99."
 RESULT:&从8/4/99&到2000年还有&150&天.&
_______________________________________________________________________________
 FUNCTION:&返回一个月的第几日 .&
 SYNTAX:&Day(date)&
 ARGUMENTS:&date&是任何有效的日期。 
 EXAMPLE:&&%=Day(#8/4/99#)%&&
 RESULT:&4&
_______________________________________________________________________________
FormatCurrency()&
 FUNCTION:&返回表达式,此表达式已被格式化为货币值 &
 SYNTAX:&FormatCurrency(Expression&[,&Digit&][,&LeadingDigit&][,&Paren&][,&
GroupDigit]]]])&
 ARGUMENTS: Digit&指示小数点右侧显示位数的数值。默认值为&-1,指示使用的是
计算机的区域设置;&LeadingDigit&三态常数,指示是否显示小数值小数点前面的
 EXAMPLE:&&%=FormatCurrency(34.3456)%&&
 RESULT:&$34.35&
_______________________________________________________________________________
FormatDateTime()&
 FUNCTION:&返回表达式,此表达式已被格式化为日期或时间&
 SYNTAX:&FormatDateTime(Date,&[,&NamedFormat])&
 ARGUMENTS:&NamedFormat&指示所使用的日期/时间格式的数值,如果省略,则使用&
vbGeneralDate.&
 EXAMPLE:&&%=FormatDateTime("08/4/99",&vbLongDate)%&&
 RESULT:&Wednesday,&August&04,&1999&
_______________________________________________________________________________
FormatNumber()&
 FUNCTION:&返回表达式,此表达式已被格式化为数值.&
 SYNTAX:&FormatNumber(Expression&[,&Digit&][,&LeadingDigit&][,&Paren&][,&
GroupDigit]]]])&
 ARGUMENTS: Digit&指示小数点右侧显示位数的数值。默认值为&-1,指示使用的是
计算机的区域设置。;&LeadingDigit&i指示小数点右侧显示位数的数值。默认值为&-
1,指示使用的是计算机的区域设置。;&Paren&指示小数点右侧显示位数的数值。默认
值为&-1,指示使用的是计算机的区域设置。;&GroupDigit&i指示小数点右侧显示位数
的数值。默认值为&-1,指示使用的是计算机的区域设置。.&
 EXAMPLE:&&%=FormatNumber(45.)%&&
 RESULT:&45.325&
_______________________________________________________________________________
FormatPercent()&
 FUNCTION:&返回表达式,此表达式已被格式化为尾随有&%&符号的百分比(乘以&
100&)。&(%)&
 SYNTAX:&FormatPercent(Expression&[,&Digit&][,&LeadingDigit&][,&Paren&][,&
GroupDigit]]]])&
 ARGUMENTS:&同上.&
 EXAMPLE:&&%=FormatPercent(0.45267,&3)%&&
 RESULT:&45.267%&
_______________________________________________________________________________
 FUNCTION:&以24时返回小时数.&
 SYNTAX:&Hour(time)&
 ARGUMENTS: 
 EXAMPLE:&&%=Hour(#4:45:34&PM#)%&&
 RESULT:&16
(Hour&has&been&converted&to&24-hour&system)&
_______________________________________________________________________________
 FUNCTION:&返回字符或字符串在另一个字符串中第一次出现的位置.&
 SYNTAX:&Instr([start,&]&strToBeSearched,&strSearchFor&[,&compare])&
 ARGUMENTS:&Start为搜索的起始值,strToBeSearched接受搜索的字符串 
strSearchFor要搜索的字符.compare比较方式(详细见ASP常数)&
 EXAMPLE:&&%
strText&=&"This&is&a&test!!"
pos&=&Instr(strText,&"a")
response.write&pos
 RESULT:&9&
_______________________________________________________________________________
InstrRev()&
 FUNCTION:&同上,只是从字符串的最后一个搜索起&
 SYNTAX:&InstrRev([start,&]&strToBeSearched,&strSearchFor&[,&compare])&
 ARGUMENTS:&同上.&
 EXAMPLE:&&%
strText&=&"This&is&a&test!!"
pos&=&InstrRev(strText,&"s")
response.write&pos
 RESULT:&13
_______________________________________________________________________________
 FUNCTION:&返回数值类型,不四舍五入,注意取值是不大于它的整数。&
 SYNTAX:&Int(number)&
 ARGUMENTS: 
 EXAMPLE:&&%=INT(32.89)%& &&%=int(-3.33)%&
 RESULT:&32  -4
_______________________________________________________________________________
IsArray()&
 FUNCTION:&判断一对象是否为数组,返回布尔值 .&
 SYNTAX:&IsArray(name)&
 ARGUMENTS: 
 EXAMPLE:&&%
strTest&=&"Test!"
response.write&IsArray(strTest)
 RESULT:&False&
_______________________________________________________________________________
 FUNCTION:&判断一对象是否为日期,返回布尔值&
 SYNTAX:&IsDate(expression)&
 ARGUMENTS:&expression&is&any&valid&expression.&
 EXAMPLE:&&%
strTest&=&"8/4/99"
response.write&IsDate(strTest)
 RESULT:&True&
_______________________________________________________________________________
IsEmpty()&
 FUNCTION:&判断一对象是否初始化,返回布尔值.&
 SYNTAX:&IsEmpty(expression)&
 ARGUMENTS: 
 EXAMPLE:&&%
response.write&IsEmpty(i)
 RESULT:&True&
_______________________________________________________________________________
 FUNCTION:&判断一对象是否为空,返回布尔值.&
 SYNTAX:&IsNull(expression)&
 ARGUMENTS: 
 EXAMPLE:&&%
response.write&IsNull(i)
 RESULT:&False&
_______________________________________________________________________________
IsNumeric()&
 FUNCTION:&判断一对象是否为数字,返回布尔值.&
 SYNTAX:&IsNumeric(expression)&
 ARGUMENTS: 
 EXAMPLE:&&%
response.write&IsNumeric(i)
 RESULT:&True
就算数字加了引号,ASP还是认为它是数字。&
_______________________________________________________________________________
IsObject()&
 FUNCTION:&判断一对象是否为对象,返回布尔值.&
 SYNTAX:&IsObject(expression)&
 ARGUMENTS: 
 EXAMPLE:&&%
Set&con&=&Server.CreateObject("ADODB.Connection")
response.write&IsObject(con)
 RESULT:&True&
_______________________________________________________________________________
 FUNCTION:&返回指定数组维的最小可用下标.&
 SYNTAX:&Lbound(arrayname&[,&dimension])&
 ARGUMENTS:&;&dimension&指明要返回哪一维下界的整数。使用&1&表示第一维,2&
表示第二维,以此类推。如果省略&dimension&参数,默认值为&1.&
 EXAMPLE:&&%
i&=&Array("Monday","Tuesday","Wednesday")
response.write&LBound(i)
 RESULT:&0&
_______________________________________________________________________________
 FUNCTION: &返回字符串的小写形式&
 SYNTAX:&Lcase(string)&
 ARGUMENTS:&string&is&any&valid&string&expression.&
 EXAMPLE:&&%
strTest&=&"This&is&a&test!"
response.write&LCase(strTest)
 RESULT:&this&is&a&test!&
_______________________________________________________________________________
 FUNCTION:&返回字符串左边第length个字符以前的字符(含第length个字符).&
 SYNTAX:&Left(string,&length)&
 ARGUMENTS: 
 EXAMPLE:&&%
strTest&=&"This&is&a&test!"
response.write&Left(strTest,&3)
 RESULT:&Thi&
_______________________________________________________________________________
 FUNCTION:&返回字符串的长度.&
 SYNTAX:&Len(string&|&varName)&
 ARGUMENTS: 
 EXAMPLE:&&%
strTest&=&"This&is&a&test!"
response.write&Len(strTest)
 RESULT:&15&
_______________________________________________________________________________
 FUNCTION:&去掉字符串左边的空格.&
 SYNTAX:&LTrim(string)&
 ARGUMENTS: 
 EXAMPLE:&&%
strTest&=&"&This&is&a&test!"
response.write&LTrim(strTest)
 RESULT:&This&is&a&test!&
_______________________________________________________________________________
 FUNCTION:&返回特定长度的字符串(从start开始,长度为length).&
 SYNTAX:&Mid(string,&start&[,&length])&
 ARGUMENTS: 
 EXAMPLE:&&%
strTest&=&"This&is&a&test!&Today&is&Monday."
response.write&Mid(strTest,&17,&5)
 RESULT:&Today&
_______________________________________________________________________________
 FUNCTION:&返回时间的分钏.&
 SYNTAX:&Minute(time)&
 ARGUMENTS: 
 EXAMPLE:&&%=Minute(#12:45:32&PM#)%&&
 RESULT:&45&
_______________________________________________________________________________
 FUNCTION:&返回日期.&
 SYNTAX:&Month(date)&
 ARGUMENTS:&date&is&any&valid&date&expression.&
 EXAMPLE:&&%=Month(#08/04/99#)%&&
 RESULT:&8&
_______________________________________________________________________________
MonthName()&
 FUNCTION:&Returns&a&string&identifying&the&specified&month.&
 SYNTAX:&MonthName(month,&[,&Abb])&
 ARGUMENTS:&month&is&the&numeric&representation&for&a&given&&Abb&
(optional)&is&a&boolean&value&used&to&display&month&abbreviation.&True&
will&display&the&abbreviated&month&name&and&False&(default)&will&not&show&
the&abbreviation.&
 EXAMPLE:&&%=MonthName(Month(#08/04/99#))%&&
 RESULT:&August&
_______________________________________________________________________________
 FUNCTION:&Returns&the&current&system&date&and&time.&
 SYNTAX:&Now()&
 ARGUMENTS:&None&
 EXAMPLE:&&%=Now%&&
 RESULT:&8/4/99&9:30:16&AM&
_______________________________________________________________________________
Replace()&
 FUNCTION:&Returns&a&string&in&which&a&specified&sub-string&has&been&
replaced&with&another&substring&a&specified&number&of&times.&
 SYNTAX:&Replace(strToBeSearched,&strSearchFor,&strReplaceWith&[,&start&
][,&count&][,&compare]]])&
 ARGUMENTS:&strToBeSearched&is&a&string&expression&containing&a&sub-
string

我要回帖

更多关于 excel文件合成sheet 的文章

 

随机推荐