博文

asp生成word文件(2007-04-17 12:43:00)

摘要:<html> <head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><meta name="GENERATOR" content="Microsoft FrontPage 5.0"><meta name="ProgId" content="FrontPage.Editor.Document"><title>生成word文档</title></head><script language="vbscript">sub builddoc()    On Error Resume Next     Dim wApp        Set wApp = CreateObject("Word.Application")    If Err.number > 0 Then        Alert "没法保存为Word文件,请正确安装Word97"    else    wApp.visible = True     wApp.Documents.add                         wApp.Selection.TypeParagraph                     wApp.Selection.Font.Bold......

阅读全文(6244) | 评论:0

清空IE缓存(2007-04-11 09:44:00)

摘要:有时候缓存会给程序带来很大的麻烦,这段代码是用来清空IE缓存里的内容1.禁止客户端缓存要在<head>中加入类似如下内): <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"> 2.在服务器的动态网页中禁止缓存,要加入类似如下脚本 (1)asp: <% Response.Expires = -1 Response.ExpiresAbsolute = Now() - 1 Response.cachecontrol = "no-cache" %> 或者<%pStr = "private, no-cache, must-revalidate" Response.ExpiresAbsolute = date() Response.AddHeader "pragma", "no-cache" Response.AddHeader "cache-control", pStr %> (2)jsp: response.setHeader("Pragma","No-cache"); response.setHeader("Cache-Control","no-cache"); response.setDateHeader("Expires", 0); ......

阅读全文(4538) | 评论:0

文章分页代码(2007-03-15 16:08:00)

摘要:<%Function c2u(myText) Dim i c2u = "" For i = 1 to Len(myText) c2u = c2u & "&#x" & Hex(AscW(Mid(myText, i, 1))) & ";" Next End Function Function cutStr(str,strlen) '去掉所有HTML标记 Dim re Set re=new RegExp re.IgnoreCase =True re.Global=True re.Pattern="<(.[^>]*)>" str=re.Replace(str,"") set re=Nothing Dim l,t,c,i l=Len(str) t=0 For i=1 to l c=Abs(Asc(Mid(str,i,1))) If c>255 Then t=t+2 Else t=t+1 End If If t>=strlen Then cutStr=left(str,i)&"..." Exit For Else cutStr=str End If Next cutStr=Replace(cutStr,chr(10),"") cutStr=Replace(cutStr,chr(13),"") End Function Function converttowide(str) Dim strlen Dim position Dim convertstr if isnull(str) then converttowide=str else position=1 strlen=Len(str) For i=1 To strlen convertstr=convertstr+"&#x"+Hex(AscW(Mid(str,position,1)))+";" position=position+1 Next converttowide=convertstr end if End Function dim topicx,usernamex,addtimex,logtextx,ispassword '获取ID号 articleid=request("articleid") '写执行语句 strSQL ......

阅读全文(4906) | 评论:1

rs.open sql,conn,1,1 参数的意思(2007-03-14 18:22:00)

摘要: 第一个参数:sql 即SQL语句 第二个数:conn 即数据库的连接 第三个参数:  0     创建只能向前滚动的只读记录集     1     游标允许你添加,删除和修改记录,但是看不到当你的记录集打开是其他用户所做的修改     2     游标允许你添加,删除和修改记录,并且可以看到其他用户所做的修改     3     创建一个具有所有定位功能的只读记录集,即:可以向前,向后,并且可以标记书签   第四个:     1     记录是只读的,并且不能改变     2     记录在你可以对其进行编辑时是被锁定的     3     在你调用Update方法提交你所做的改变时记录是被锁定的     4     如果你在对一系列记录进行批量更新,在需要它......

阅读全文(4197) | 评论:1

asp如何检测conn.execute执行成功?(2007-03-02 14:23:00)

摘要:sql="update ……"conn.execute(sql)如何检测conn.execute更新成功?   dim asql="update ……"conn.execute sql,aif a=1 then response.write "更新成功"else response.write "更新失败"end if  ......

阅读全文(4122) | 评论:0

asp调用SQL Server存储过程(2007-03-02 13:19:00)

摘要:说明:1、使用存储过程比asp直接使用SQL语句速度快得多! 2、asp调用SQL Server存储过程时,经常用到一些参数,如果你没有定义或加载adovbs.inc文件,就会出错,所以你可以直接定义,或试用该参数的替代数字!详见存储过程初级篇:SQL Server存储过程的建立和使用   1.数据库链接文件:include.asp使用方式:<!--#include file="include/conn.asp"-->     '//假设数据库文件放在include目录下<%dim conndim connstron error resume next Sub OpenConn()   '//建立数据库链接 connstr="DRIVER={SQL Server};Server=127.0.0.1;UID=badboy;PWD=badyboyILoveYou;database=BadBoyDB" set conn=server.createobject("ADODB.CONNECTION") conn.open connstr If Err Then  err.Clear  Set Conn = Nothing  Response.Write "数据库连接出错,请检查连接字串。"  Response.End End IfEnd Sub Sub CloseConn()   '//断开数据库链接 conn.close set conn=nothingEnd Sub%> 2.调用数据库存储过程 <% Call OpenConn()           '//建立连接对象    '// 1)ADO标准方法,缺点:当存储过程中有两个以上的SELECT语句,但从逻辑上又不可能同时执行的时候,ADO会提示你存储过程中SELECT语句太多  Set cmdSP = S......

阅读全文(6743) | 评论:0

如何得到url="http://www.aaa.com/?25中的25(2007-02-13 09:24:00)

摘要:url="http://www.aaa.com/?25如何得到25这个值? 方法:<% for each var in request.QueryString response.write var next %> ......

阅读全文(4225) | 评论:0

获取本页的URL地址(2007-02-13 09:15:00)

摘要:<%Function GetLocationURL() Dim Url Dim ServerPort,ServerName,ScriptName,QueryString ServerName = Request.ServerVariables("SERVER_NAME") ServerPort = Request.ServerVariables("SERVER_PORT") ScriptName = Request.ServerVariables("SCRIPT_NAME") QueryString = Request.ServerVariables("QUERY_STRING") Url="http://"&ServerName If ServerPort <> "80" Then Url = Url & ":" & ServerPort Url=Url&ScriptName If QueryString <>"" Then Url=Url&"?"& QueryString GetLocationURL=Url End Function Response.Write GetLocationURL() %>......

阅读全文(4731) | 评论:0

Cookies常用命令简介(2007-01-30 15:30:00)

摘要:什么是Cookies?Cookies是数据包,可以让网页具有记忆功能,在某台电脑上记忆一定的信息。Cookies的工作原理是,第一次由服务器端写入到客户端的系统中。以后每次访问这个网页,都是先由客户端将Cookies发送到服务器端,再由服务器端进行判断,然后再产生HTML代码返回给客户端,这是一个很重要的原理。关于服务器端和客户端的概念,请点击我写的这篇:什么是服务器端和客户端,举了2个实例。 Cookies在ASP中的最常用的方法,请做好笔记: 1.如何写入Cookies?Response.Cookies("字段名")=变量或字符串,例如:Response.Cookies("str")="username" 2.如何设置Cookies时间?Response.Cookies("字段名").expires=时间函数+N,例如:Response.Cookies("str").expires=date+1,表示Cookies保存1天,再比如:Response.Cookies("str").expires=Hour+8,表示Cookies保存8小时。 3.在以往的ASP教程中,很少有介绍Cookies退出的方法。在“退出”这个ASP页中可以这样写:Response.Cookies("字段名")=""之后,在客户端的浏览器就清除了Cookies,并且Cookies文件会消失。注意有多少个字段,就要写多少句来清除。 4.如何读取Cookies?变量名=Request.Cookies("字段名"),例如:str=Request.Cookies("str")如果网页中写入<%=str%>这句,则会显示“username”。也可以这样直接读取Cookies,<%=Request.Cookies("str")%> Cookies是属于Session对象的一种。但有不同,Cookies不会占服务器资源;而“Session”则会占用服务器资源。所以,尽量不要使用Session,而使用Cookies。......

阅读全文(3671) | 评论:0

只去掉html中的链接(2007-01-09 14:31:00)

摘要:<p><a href='1.html'>11111</a></p><p>2222</p> <p><a href='2.html'>3333</a></p><p>44444</p> 想得到的结果是: <p>11111</p><p>2222</p><p>3333</p><p>4444</p> <%Function regExReplace(sSource,patrn, replStr) Dim regEx, str1 str1 = sSource Set regEx = New RegExp regEx.Pattern = patrn regEx.IgnoreCase = True regEx.Global = True regExReplace = regEx.Replace(str1, replStr) End Function dim c1,c2 c1="<p><a href='1.html'>11111</a></p><p>2222</p> <p><a href='2.html'>3333</a></p><p>44444</p> " c2=regExReplace(c1,"<a.*?>|</a>","")response.Write(c2) %>......

阅读全文(3017) | 评论:0