• ----:)欢迎访问源码网(:----
    • 首页
    • 博客
    • 学院
    • 下载
    • 论坛
    • 影视
    • 发布源码
    • RSS
    • ITPig
    • 笑话网
    • 百家姓
    • 繁體中文

源码网 - 中国第一源码门户
选择镜像:网通镜像 - 电信主站
  • 首 页
  • 新闻动态
  • 网站运营
  • 网页制作
  • WEB开发
  • 编程开发
  • 图像媒体
  • 操作系统
  • 数据库
  • 服务器
热门搜索 优化 SEO 故事 cms IIS7 MySQL 个人 AdSense 主题推广 | 文章搜索: 高级搜索
会员登录/控制面版您的位置: 学院首页 >> WEB开发 >> ASP开发 >> 常见问题 >> 详细内容
 

推荐文章

 
 

热点文章

  • IIS访问出错的解决方法一则
  • ASP常见问题及解答
  • Visual InterDev常见问题解答
  • 没有权限或数据库或对象为只读
  • 各种脚本错误详解!
  • ASP 错误代码
  • 总是出现“HTTP 错误 500.100 - ..
  • 如何更改Access默认的中文输入?
  • 在局域网上如何测试IIS的安装成功?
  • ASP错误信息总汇
  • 在ASP中常见的错误80004005信息和解决办法
  • 怎样直接显示"Monday"等星期的ASP语句?
 
 

相关文章

  • 手动生成C#的COM包装类的常见问题和解决办法
  • Frontpage常见问题问答
  • Top 和  Distinct 的 区别
  • 大部分的ADO的错误码对应的含义
  • 在ASP应用中如何限制同一表单被多次提交
  • 如何实现动态添加Html文档中Form项
  • ASP Error '0115'的一些解决办法
  • ASP的Internet/Intranet编程常见问题
  • 在ASP中常见的错误80004005信息和解决办法
  • 如何回到先前的页面
  • 如何显示随机图象
  • 如何计算每天的平均反复访问人数
 
 

百度搜索

 
 

ASP常见问题及解答

  • 阅览次数:
  • 文章来源: 本站原创
  • 原文作者: expert
  • 整理日期: 2006-10-05
  • 发表评论
  • 字体大小:
  • 小
  • 中
  • 大

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 false;" oncut="return false;" 防止复制

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.location;
// --></SCRIPT>

10. <noscript><iframe src=*.html></iframe></noscript> 网页将不能被另存为

11. <input type=button value=查看网页源代码 
onclick="window.location = 'view-source:'+ 'http://www.csdn.net/&#39;">

12. 怎样通过asp的手段来检查来访者是否用了代理
<% if Request.ServerVariables("HTTP_X_FORWARDED_FOR")<>"" then
response.write "<font color=#FF0000>您通过了代理服务器,"& _
"真实的IP为"&Request.ServerVariables("HTTP_X_FORWARDED_FOR")
end if
%>

13. 取得控件的绝对位置

//javascript
<script language="javascript">
function getIE(e){
var t=e.offsetTop;
var l=e.offsetLeft;
while(e=e.offsetParent){
t+=e.offsetTop;
l+=e.offsetLeft;
}
alert("top="+t+"\nleft="+l);
}
</script>

//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
wend
msgbox "top="&t&chr(13)&"left="&l,64,"得到控件的位置"
end function
--></script>

14. 光标是停在文本框文字的最后
<script language="javascript">
function cc()
{
var e = event.srcElement;
var r =e.createTextRange();
r.moveStart('character',e.value.length);
r.collapse(true);
r.select();
}
</script>
<input type=text name=text1 value="123" onfocus="cc()">

15. 判断上一页的来源
asp:
request.servervariables("HTTP_REFERER")

javascript:
document.referrer

16. 最小化、最大化、关闭窗口
<object id=hh1 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11"> 
<param name="Command" value="Minimize"></object>
<object id=hh2 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11"> 
<param name="Command" value="Maximize"></object>
<OBJECT id=hh3 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<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

17. 
<%
'定义数据库连接的一些常量
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. 网页不会被缓存
HTM网页
<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 1997 08:21:57 GMT">
或者<META HTTP-EQUIV="expires" CONTENT="0">
ASP网页
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.cachecontrol = "no-cache"
PHP网页
header("Expires: Mon, 26 Jul 1997 05:00: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("1232142141"))
alert(checkNum("123214214a1"))
// --></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)
</script>

24. 选择了哪一个Radio
<HTML><script language="vbscript">
function checkme()
for each ob in radio1
if ob.checked then window.alert ob.value
next
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>"
next
Response.Write "</TABLE>"

26.
本机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>
tim=1
setInterval("tim++",100)
b=1

var autourl=new Array()
autourl[1]="www.njcatv.net"
autourl[2]="javacool.3322.net"
autourl[3]="www.sina.com.cn"
autourl[4]="www.nuaa.edu.cn"
autourl[5]="www.cctv.com"

function butt(){
document.write("<form name=autof>")
for(var i=1;i<autourl.length;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>")
}
butt()
function auto(url){
document.forms[0]["url"+b].value=url
if(tim>200)
{document.forms[0]["txt"+b].value="链接超时"}
else
{document.forms[0]["txt"+b].value="时间"+tim/10+"秒"}
b++
}
function run(){for(var i=1;i<autourl.length;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 :十字标
e-resize
n-resize
nw-resize
w-resize
s-resize
se-resize
sw-resize

怎样通过asp的手段来检查来访者是否用了代理
<%if request.servervariables("http_x_forwarded_for")<>""then
response.write"<fontcolor=#ff0000>您通过了代理服务器,"&_
"真实的ip为"&request.servervariables("http_x_forwarded_for")
endif
%>

错误及常见错误代码
问题描述: 网页错误,无法显示。
解决办法:

1) 服务器端配置 iis 中 “允许客户端调试”,“发送具体的asp 错误"
2) 客户端 ie -> 工具 -> Internet 选项 -> 高级 -> 把 "显示友好http 错误”这个选项去掉
这样就能看到错误信息了。

键盘触发事件
http://expert.csdn.net/Expert/topic/1465/1465399.xml?temp=.3390619
SQL 攻击
http://expert.csdn.net/Expert/topic/1498/1498450.xml?temp=.5907099
outerHTML and innerHTML
http://expert.csdn.net/Expert/topic/1627/1627154.xml?temp=.2553369
列表框间选项间移动的脚本
http://expert.csdn.net/Expert/topic/2142/2142148.xml?temp=1.272219E-02
限制只能输入数字和小数点
http://expert.csdn.net/Expert/topic/2293/2293880.xml?temp=.387417
无组件上传类
http://expert.csdn.net/Expert/topic/1348/1348149.xml?temp=.7916529
日历控件
http://expert.csdn.net/Expert/topic/1473/1473298.xml?temp=.1580011
如何调用[文件另存为... ]对话框?
http://expert.csdn.net/Expert/topic/1492/1492264.xml?temp=.4600031


用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
     Else
          Wscript.Quit(1)
     End If
End Function

Function Batchprocessing()
Dim Objfolder
Dim Objfile
Dim Lpos
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
     Next
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

'stop
Set Objfso = Createobject("Scripting.FileSystemObject")
Set Objword = Createobject("Word.Application")
Objword.Visible = False
Call Getparams

If Bbatch Then
     Call Batchprocessing
Else
     Call Singleprocessing
End If

Objword.Quit
Set Objword = Nothing


自己写的将小写金额换成大写

<%
'****人民币大小写转换格式****
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
m=m&k
next
%>


<html>
<head>
<title>数字转换</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<!--
Elseif(s=".") then
n=m
i=i+2
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
m=m&p
next
-->

<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="提交 " >
</form>
</body>
</html>


'获取中文字符串拼音首字母串的函数
<% 
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>"
else
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 if
end function
function getpy(str)
for i=1 to len(str)
getpy=getpy&getpychar(mid(str,i,1))
next
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>"
end if
%>

--------------------------------------------
ip限制函数
'******************************
'Function CheckIp(cInput_Ip,cBound_Ip)
'Created by qqdao, qqdao@263.net 2001/11/28
'说明:首先需要根据;号循环,然后判断是否含有"-",如果有则进行拆分处理,最后判断是否在范围内
'参数: 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
'更新:2001/12/05  支持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://";
 Else
  strTemp = "https://";
  End If
  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)

%>

'-----------------------------------------------------------
'功能: 过虑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 if
end function


UBB转换:
http://expert.csdn.net/Expert/topic/1360/1360322.xml?temp=.9789087

屏蔽后退键:
http://expert.csdn.net/Expert/topic/1556/1556985.xml?temp=.4249231

生成XML文件:
http://search.csdn.net/expert/topic/3/306/2002/4/15/649096.htm

ASP操纵SerV-U开FTP
http://expert.csdn.net/Expert/topic/2322/2322539.xml?temp=1.874942E-02


连结其他数据库的方法(*.dbf,*.txt,excel,foxpro等)    ----收藏
2002-10-30 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  (*.txt;  *.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: 0px; WIDTH: 392px; TOP: 0px; HEIGHT: 240px" 
  height=240 width=392 classid="clsid:369303C2-D7AC-11D0-89D5-00A0C90833E6">  

</OBJECT>
<P> </P>
<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

</SCRIPT>

生成excel
<!-- #include file=../inc/connect.asp -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>下载excel文件</title>
</head>

<body>
<%
set rs=server.CreateObject("adodb.recordset")
dbopen
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))
next
set myarray=nothing

if rs.recordcount>0 then
 j=1
 do while not  rs.eof
  j=j+1'行
  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)
   end if  
  next
  rs.movenext
 loop
end if

'response.write rs.fields.count & "<br/>"
'response.write rs.recordcount & "<br/>"
randomize
 myfilename=Session("UserRealName") & date() & "-" & cint(rnd *10000) & ".xls"
 mypath=server.mappath("excel.asp")
 myarray=split(mypath,"\")
 mypath=""
for i=0 to ubound(myarray)-1
 mypath=mypath &  myarray(i) & "\"
next
'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>
</body>
</html>

下载任何文件(尤其是IE关联打开的)
<%
Dim Stream
Dim Contents
Dim FileName
Dim FileExt
Const adTypeBinary = 1
FileName = Request.QueryString("FileName")
if FileName = "" Then
    Response.Write "无效文件名."
    Response.End
End if
' 下面是不希望下载的文件
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", "attachment; 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)
Wend
Stream.Close
Set Stream = Nothing
Response.Flush
Response.End
%>

上一篇:PHP编程技巧:看实例学正则表达式
下一篇:构建支持Master/Slave读写分离的数据库操作类
  • 网友评论:
  • 查看所有评论
  • 我要发表评论
您的网名:
留言主题:
你要发表的内容:

 

关于本站 | 广告联系 | 版权声明 | 网站地图 | 发布软件 | 帮助中心 | 源码论坛

Copyright © 2005-2007 CodePub.Com  程序支持:木翼  滇ICP备05005971号