微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!
ASP函数大全
Array()CInt()CStr()Date()DateAdd()Day()FormatCurrency()FormatDateTime()FormatNumber()FormatPercent()Instr()InstrRev()Int()IsArray()IsDate()IsNull()IsNumeric()IsObject()LBound()LCase()Len()LTrim()Mid()Minute()Month()Now()Right()Rnd()Round()Rtrim()Second()StrReverse()Time()Trim()UBound()VarType()WeekDay()WeekDayName()Year()MonthName()DateDiff()Hour()IsEmpty()Left()Split()UCase() ASP函数与VBSCRIPT类似,以下举一些常用的函数Array()函数返回一个数组表达式 Array(list)允许数据类型: 字符,数字均可实例:<%Dim myArray()For i = 1 to 7Redim Preserve myArray(i)myArray(i) = WeekdayName(i)Next%>返回结果: 建立了一个包含7个元素的数组myArraymyArray("Sunday","Monday", ... ... "Saturday")CInt()函数将一个表达式转化为数字类型表达式 CInt(expression)允许数据类型: 任何有效的字符均可实例:<%f = "234"response.write cINT(f) + 2%>返回结果: 236转化字符"234"为数字"234",如果字符串为空,则返回0值CreateObject()函数建立和返回一个已注册的ACTIVEX组件的实例。表达式 CreateObject(objName)允许数据类型: objName 是任何一个有效、已注册的ACTIVEX组件的名字.实例: <%Set con = Server.CreateObject("ADODB.Connection")%>CStr()函数转化一个表达式为字符串.表达式 CStr(expression)允许数据类型: expression 是任何有效的表达式。实例: <%s = 3 + 2response.write "The 返回结果 is: " & cStr(s)%>返回结果: 转化数字“5”为字符“5”。Date()函数返回当前系统日期.表达式 Date()允许数据类型: None.实例: <%=Date%>返回结果: 9/9/00DateAdd()函数返回一个被改变了的日期。表达式 DateAdd(timeinterval,number,date)允许数据类型:timeinterval is the time interval to add;number is amount of time intervals to add;and date is the starting date.实例: <%currentDate = #9/9/00#newDate = DateAdd("m",3,currentDate)response.write newDate%><%currentDate = #12:34:45 PM#newDate = DateAdd("h",3,currentDate)response.write newDate%>返回结果: 9/9/003:34:45 PM"m" = "month";"d" = "day";If currentDate is in time format then,"h" = "hour";"s" = "second";DateDiff()函数返回两个日期之间的差值 。表达式 DateDiff(timeinterval,date1,date2 [, firstdayofweek [, firstweekofyear]])允许数据类型: timeinterval 表示相隔时间的类型,如“M“表示“月”。实例: <%fromDate = #9/9/00#toDate = #1/1/2000#response.write "There are " & _DateDiff("d",fromDate,toDate) & _" days to millenium from 9/9/00."%>返回结果: 从9/9/00 到2000年还有 150 天.Day()函数返回一个月的第几日 .表达式 Day(date)允许数据类型: date 是任何有效的日期。实例: <%=Day(#9/9/00#)%>返回结果: 4FormatCurrency()函数返回表达式,此表达式已被格式化为货币值表达式 FormatCurrency(Expression [, Digit [, LeadingDigit [, Paren [, GroupDigit]]]])允许数据类型: Digit 指示小数点右侧显示位数的数值。默认值为 -1,指示使用的是计算机的区域设置; LeadingDigit 三态常数,指示是否显示小数值小数点前面的零。实例: <%=FormatCurrency(34.3456)%>返回结果: $34.35FormatDateTime()函数返回表达式,此表达式已被格式化为日期或时间表达式 FormatDateTime(Date, [, NamedFormat])允许数据类型: NamedFormat 指示所使用的日期/时间格式的数值,如果省略,则使用 vbGeneralDate.实例: <%=FormatDateTime("09/9/00", vbLongDate)%>返回结果: Sunday, September 09, 2000FormatNumber()函数返回表达式,此表达式已被格式化为数值.表达式 FormatNumber(Expression [, Digit [, LeadingDigit [, Paren [, GroupDigit]]]])允许数据类型: Digit 指示小数点右侧显示位数的数值。默认值为 -1,指示使用的是计算机的区域设置。; LeadingDigit i指示小数点右侧显示位数的数值。默认值为 -1,指示使用的是计算机的区域设置。; Paren 指示小数点右侧显示位数的数值。默认值为 -1,指示使用的是计算机的区域设置。; GroupDigit i指示小数点右侧显示位数的数值。默认值为 -1,指示使用的是计算机的区域设置。.实例: <%=FormatNumber(45.324567, 3)%>返回结果: 45.325FormatPercent()函数返回表达式,此表达式已被格式化为尾随有 % 符号的百分比(乘以 100 )。 (%)表达式 FormatPercent(Expression [, Digit [, LeadingDigit [, Paren [, GroupDigit]]]])允许数据类型: 同上.实例: <%=FormatPercent(0.45267, 3)%>返回结果: 45.267%Hour()函数以24时返回小时数.表达式 Hour(time)允许数据类型:实例: <%=Hour(#4:45:34 PM#)%>返回结果: 16(Hour has been converted to 24-hour system)Instr()函数返回字符或字符串在另一个字符串中第一次出现的位置.表达式 Instr([start, ] strToBeSearched, strSearchFor [, compare])允许数据类型: Start为搜索的起始值,strToBeSearched接受搜索的字符串 strSearchFor要搜索的字符.compare比较方式(详细见ASP常数)实例: <%strText = "This is a test!!"pos = Instr(strText, "a")response.write pos%>返回结果: 9InstrRev()函数同上,只是从字符串的最后一个搜索起表达式 InstrRev([start, ] strToBeSearched, strSearchFor [, compare])允许数据类型: 同上.实例: <%strText = "This is a test!!"pos = InstrRev(strText, "s")response.write pos%>返回结果: 13Int()函数返回数值类型,不四舍五入。表达式 Int(number)允许数据类型:实例: <%=INT(32.89)%>返回结果: 32IsArray()函数判断一对象是否为数组,返回布尔值 .表达式 IsArray(name)实例: <%strTest = "Test!"response.write IsArray(strTest)%>返回结果: FalseIsDate()函数判断一对象是否为日期,返回布尔值表达式 IsDate(expression)实例: <%strTest = "9/4/2000"response.write IsDate(strTest)%>返回结果: TrueIsEmpty()函数判断一对象是否初始化,返回布尔值.表达式 IsEmpty(expression)实例: <%Dim iresponse.write IsEmpty(i)%>返回结果: TrueIsNull()函数判断一对象是否为空,返回布尔值.表达式 IsNull(expression)实例: <%Dim iresponse.write IsNull(i)%>返回结果: FalseIsNumeric()函数判断一对象是否为数字,返回布尔值.表达式 IsNumeric(expression)实例: <%i = "345"response.write IsNumeric(i)%>返回结果: True就算数字加了引号,ASP还是认为它是数字。IsObject()函数判断一对象是否为对象,返回布尔值.表达式 IsObject(expression)实例: <%Set con = Server.CreateObject("ADODB.Connection")response.write IsObject(con)%>返回结果: TrueLBound()函数返回指定数组维的最小可用下标.表达式 Lbound(arrayname [, dimension])实例: <%i = Array("Monday","Tuesday","Wednesday")response.write LBound(i)%>返回结果: 0LCase()函数 返回字符串的小写形式表达式 Lcase(string)实例: <%strTest = "This is a test!"response.write LCase(strTest)%>返回结果: this is a test!Left()函数返回字符串左边第length个字符以前的字符(含第length个字符)
Server.MapPath(path)的使用
用法:1.Server.MapPath("/") 应用程序根目录所在的位置 如 C:Inetpubwwwroot2.Server.MapPath("./") 表示所在页面的当前目录    注:等价于Server.MapPath("") 返回 Server.MapPath("")所在页面的物理文件路径3.Server.MapPath("../")表示上一级目录4.Server.MapPath("~/")表示当前应用级程序的目录,如果是根目录,就是根目录,如果是虚拟目录,就是虚拟目录所在的位置 如:C:InetpubwwwrootExample注:等效于Server.MapPath("~")。语法:Server.MapPath(bstrLogicalPath)作用:将 bstrLogicalPath 映射为计算机上的物理目录,注意此物理目录可以也可能不存在。参数:bstrLogicalPath 的意思是相对目录*或虚拟目录。疑问:bstrLogicalPath 既然既可以表示相对目录,又可以表示虚拟目录,那么它什么时候表示相对目录,什么时候表示虚拟目录呢。规则:当 bstrLogicalPath 以 ../ 或 .. 开头时,当作相对目录。 <当 bstrLogicalPath 以斜杠开头( / 或 )时,从Web站点根目录(不是物理目录)的角度出发检查是否有匹配的虚拟目录(树)**,如果匹配,则当作虚拟目录,否则当作相对目录。当 bstrLogicalPath 不以斜杠开头( / 或 )时,从Web站点当前目录(不是物理目录)的角度出发检查是否有匹配的虚拟目录(树)**,如果匹配,则当作虚拟目录,否则当作相对目录。*也可以是文件。**由于虚拟目录下面可以再建立虚拟目录,所以这里使用虚拟目录树,即:每一层的目录或虚拟目录都要与 bstrLogicalPath 中的对应目录层匹配。***bstrLogicalPath 中含有英文点(.)或以斜杠结尾( / 或 )不影响上述规则。
详谈asp生成静态页方法
生成静态页的好处不用说,当今大型网站,为缓解服务器端的压力许的的页面都改用了静态的页面,并利用AJAX技术动态地更新其中的部分内容,如广告等。一个简单的不用模板可以直接生成HTML静态页的方法.如一个正常的index.asp动态页面,新建一个文件 makeasp2html.asp<form method="post" action="">      <textarea name="asp2html" display:none"><!--#include file="index.asp"--></textarea>     <input type="submit" value="生成html页"/> </form> <% If request.Form("asp2html")<>"" then     filename="index.html"     set fso = Server.CreateObject("Scripting.FileSystemObject")     set fout = fso.CreateTextFile(server.mappath(""&filename&""))     fout.write request.form("asp2html")     fout.close     set fout=nothing     set fso=nothing end if %> 这样index.html文件就生成了,连模板都用不着,只要服务器要支持FSO,将正常情况下使用的ASP文件读取到textarea里就可以了。------------------------------------------------------------------------------------------------------细说一下常用的几种生成HTML的方法:生成HTML方法主要步骤只有两个:一、获取要生成的html文件的内容二、将获取的html文件内容保存为html文件我在这里主要说明的只是第一步:如何获取要生成的html文件的内容:目前常用获取html文件的内容的方法有几下几种:1、CODE: [Copy to clipboard] str="内容标记>"str=str&"内容标记>数据库读取内容....标记>....."这种方法与是在脚本内写要生成的html内容,不太方便预览生成页面的内容,无法可视化布局页面,更改html模板时会更加复杂。用这种方法的人很多,但我感觉这种方法是最不方便的。2、制作单独的HTML模板页,动态的内容用特定的字符作为标记(如:有人用$title$标记为网页标题),用ADODB.Stream或者Scripting.FileSystemObject将其模板内容载入,然后再用替换方法把原先定好的标记替换为动态内容(如:Replace(载入的模板内容,"$title$",rs("title" ) ) )。3、用XMLHTTP或serverXMLHTTP获取动态页所显示的HTML内容,CODE: [Copy to clipboard] 我常用的生成html文件的实例:'weburl是要获取的动态页地址'getHTTPPage(weburl)是获取动态页内容的函数weburl="http://"&Request.ServerVariables("SERVER_NAME")&"/contact.asp?id="&rs("id")&""‘指定动态页地址body=getHTTPPage(weburl)'用函数取到动态页地址的内容此方法最大的好处就是不用费力气专门去写静态的模板页面,只是将原来就有的动态页面转换为HTML静态页面,但生成速度不是太快。我常用的生成HTML的方法就是第3种:用XMLHTTP获取动态页生成的HTML内容,再用ADODB.Stream或者Scripting.FileSystemObject保存成html文件。第二步是生成文件的方法:ASP里常用的有用ADODB.Stream生成文件和Scripting.FileSystemObject生成文件两种1、Scripting.FileSystemObject生成文件方法:CODE: [Copy to clipboard] Set fso = CreateObject("Scripting.FileSystemObject")File=Server.MapPath("要生成文件路径和文件名.htm")Set txt=fso.OpenTextFile(File,8,True)  data1="文件内容"用WriteLine方法生成文件txt.WriteLine data1data2="文件内容"'用Write方法生成文件txt.Write data2txt.Closetxt.fso2、ADODB.Stream生成文件方法:CODE: [Copy to clipboard] Dim objAdoStreamset objAdoStream = Server.createObject("ADODB.Stream")objAdoStream.Type = 1objAdoStream.Open()objAdoStream.Write("文件内容")objAdoStream.SaveToFile 要生成文件路径和文件名.htm,2[next] objAdoStream.Close()再说一下我对HTML防采集却不防搜索引擎蜘蛛的一些经验:  我开发过几个采集程序,也研究过很多采集程序代码,所以对采集程序的原理还算是稍微有些了解。先说一下采集原理:采集程序的主要步骤如下:一、获取被采集的页面的内容二、从获取代码中提取所有用的数据一、获取被采集的页面的内容我目前所掌握的ASP常用获取被采集的页面的内容方法:1、用serverXMLHTTP组件获取数据CODE: [Copy to clipboard] Function GetBody(weburl)     '创建对象    Dim ObjXMLHTTP    Set ObjXMLHTTP=Server.CreateObject("MSXML2.serverXMLHTTP")    '请求文件,以异步形式    ObjXMLHTTP.Open "GET",weburl,False    ObjXMLHTTP.send    While ObjXMLHTTP.readyState <> 4        ObjXMLHTTP.waitForResponse 1000    Wend    '得到结果     GetBody=ObjXMLHTTP.responseBody    '释放对象     Set ObjXMLHTTP=NothingEnd Function调用方法:GetBody(文件的URLf地址) 2、或XMLHTTP组件获取数据CODE: [Copy to clipboard] Function GetBody(weburl)     '创建对象    Set Retrieval = CreateObject("Microsoft.XMLHTTP")     With Retrieval      .Open "Get", weburl, False, "", ""      .Send      GetBody = .ResponseBody     End With     '释放对象    Set Retrieval = Nothing End Function调用方法:GetBody(文件的URLf地址) 这样获取的数据内容还需要进行编码转换才可以使用CODE: [Copy to clipboard] Function BytesToBstr(body,Cset)        dim objstream        set objstream = Server.CreateObject("adodb.stream")        objstream.Type = 1        objstream.Mode =3        objstream.Open        objstream.Write body        objstream.Position = 0        objstream.Type = 2        objstream.Charset = Cset        BytesToBstr = objstream.ReadText         objstream.Close        set objstream = nothingEnd Function调用方法:BytesToBstr(要转换的数据,编码)'编码常用为GB2312和UTF-8二、从获取代码中提取所有用的数据目前我掌握的方法有:1、用ASP内置的MID函数截取需要的数据CODE: [Copy to clipboard] Function body(wstr,start,over)start=Newstring(wstr,start)'设置需要处理的数据的唯一的开始标记over=Newstring(wstr,over)'和start相对应的就是需要处理的数据的唯一的结束标记body=mid(wstr,start,over-start)'设置显示页面的范围End Function调用方法:body(被采集的页面的内容,开始标记,结束标记)2、用正则获取需要的数据CODE: [Copy to clipboard] Function body(wstr,start,over)Set xiaoqi = New Regexp'设置配置对象xiaoqi.IgnoreCase = True'忽略大小写xiaoqi.Global = True'设置为全文搜索xiaoqi.Pattern =  "”&start&“.+?”&over&“"'正则表达式 Set Matches =xiaoqi.Execute(wstr)'开始执行配置[next] set  xiaoqi=nothing body=""For Each Match in Matchesbody=body&Match.Value '循环匹配Next  End Function调用方法:body(被采集的页面的内容,开始标记,结束标记)采集程序祥细思路:1、取得网站的分页列表页的每页地址目前绝大部分动态网站的分页地址都有规则,如:动态页第一页:index.asp?page=1第二页:index.asp?page=2第三页:index.asp?page=3.....静态页第一页:page_1.htm第二页:page_2.htm第三页:page_3.htm.....取得网站的分页列表页的每页地址,只需要用变量替代每页地址的变化的字符即可如:page_.htm2、获取被采集网站的分页列表页内容3、从分页列表代码中提取被采集的内容页面的URL连接地址绝大部分分页页面里的内容页连接也有固
超长文章分页并生成静态页实例
set rsn=server.CreateObject("adodb.recordset")sqln="select top 1 * from vArticle where apage='"&abname&"'"rsn.open sqln,conn,1,1if not rsn.eof then'do while not rsn.eof'page_n=len(rsn("aContent"))-len(replace(rsn("aContent"),"[NextPage]",""))page_n=split(rsn("aContent"),"[NextPage]")for i=1 to Ubound(page_n)+1set rs=server.CreateObject("adodb.recordset")sql="select * from hy_moban where mname='资讯内页'"rs.open sql,conn,1,1okfile=rs("mcontent")rs.closeset rs=nothing'if i=1 then 'ppage=1 'else 'ppage=i-1 'end if 'if i=1 and page_n+1>i then 'npage=i+1 'else 'npage=page_n+1 'end ifaFrom=split(rsn("aFrom")&"|","|")if aFrom(0)="" thennaFrom="未知"elsenaFrom=aFrom(0)end ifk=i-1Ntitle=rsn("aTitle")&"|"&rsn("akeyword")okfile=replace(okfile,"$Ntitle$",Ntitle)okfile=replace(okfile,"$C_Title$",rsn("C_Title"))okfile=replace(okfile,"$aTitle$",rsn("aTitle"))okfile=replace(okfile,"$acount$",rsn("acount"))okfile=replace(okfile,"$aIntime$",rsn("aIntime"))okfile=replace(okfile,"$aFrom$",naFrom)okfile=replace(okfile,"$aContent$",page_n(k))okfile=replace(okfile,"$aInUser$",rsn("aInUser"))apage=replace(rsn("apage"),".shtml","")asetpage=""for j=1 to Ubound(page_n)+1if j=i thenasetpage=asetpage&"[<font color=red>"&i&"</font>]"elseif j=1 thenasetpage=asetpage&"[<a href="&rsn("apage")&">"&j&"</a>]"elseasetpage=asetpage&"[<a href="&apage&"-haowai-"&j&".shtml>"&j&"</a>]"end ifnext'asetpage="<br><a href="""&apage&"_"&ppage&".shtml"">上一页</a> <a href="""&apage&"_"&npage&".shtml"">下一页</a>"okfile=replace(okfile,"$aSetpage$",asetpage)myear=year(rsn("aInTime"))&"-"&month(rsn("aInTime"))if i=1 thenmypage=rsn("apage")elsemypage=apage&"-haowai-"&i&".shtml"end ifSet fso1 = Server.CreateObject("Scripting.FileSystemObject")  Set fout1 = fso1.Createtextfile(Server.MapPath("/"&"article/"&myear&"/"&mypage),true) fout1.writeline okfilefout1.close'rsn.movenext'loopnextend ifrsn.closeset rsn=nothing
ASP导入Excel数据到SQL
 <form action="insert.asp" method="post" enctype="multipart/form-data" name="form1" onSubmit="b1_onclick()">  <table width="500" border="1" align="center" cellpadding="0" cellspacing="0">    <tr>      <td colspan="2" bgcolor="#999999" class="t">选择文件</td>    </tr>    <tr>      <td colspan="2" class="t">&nbsp;</td>    </tr>    <tr>      <td width="126" class="t">选择文件(excel)</td>      <td width="368" class="t"><label>        <input name="filexls" type="file" size="35">      </label></td>    </tr>    <tr>      <td colspan="2" class="t">        <label>        <input type="submit" name="Submit" value="导入数据">        </label>  <a href="1122.asp" class="t">返回</a>     </td>    </tr>  </table></form>   <!--#include virtual="/inc/clsdbctrl.asp"--><!--#include virtual="/inc/function.asp"--><%dim upfile_5xSoft_StreamClass upload_5xSoftdim Form,File,VersionPrivate Sub Class_Initializedim iStart,iFileNameStart,iFileNameEnd,iEnd,vbEnter,iFormStart,iFormEnd,theFiledim strDiv,mFormName,mFormValue,mFileName,mFileSize,mFilePath,iDivLen,mStrVersion="任翔专用上传程序"if Request.TotalBytes<1 then Exit Subset Form=CreateObject("Scripting.Dictionary")set File=CreateObject("Scripting.Dictionary")set upfile_5xSoft_Stream=CreateObject("Adodb.Stream")upfile_5xSoft_Stream.mode=3upfile_5xSoft_Stream.type=1upfile_5xSoft_Stream.openupfile_5xSoft_Stream.write Request.BinaryRead(Request.TotalBytes)vbEnter=Chr(13)&Chr(10)iDivLen=inString(1,vbEnter)+1strDiv=subString(1,iDivLen)iFormStart=iDivLeniFormEnd=inString(iformStart,strDiv)-1while iFormStart < iFormEndiStart=inString(iFormStart,"name=""")iEnd=inString(iStart+6,"""")mFormName=subString(iStart+6,iEnd-iStart-6)iFileNameStart=inString(iEnd+1,"filename=""")if iFileNameStart>0 and iFileNameStart<iFormEnd theniFileNameEnd=inString(iFileNameStart+10,"""")mFileName=subString(iFileNameStart+10,iFileNameEnd-iFileNameStart-10)iStart=inString(iFileNameEnd+1,vbEnter&vbEnter)iEnd=inString(iStart+4,vbEnter&strDiv)if iEnd>iStart thenmFileSize=iEnd-iStart-4elsemFileSize=0end ifset theFile=new FileInfotheFile.FileName=getFileName(mFileName)theFile.FilePath=getFilePath(mFileName)theFile.FileSize=mFileSizetheFile.FileStart=iStart+4theFile.FormName=FormNamefile.add mFormName,theFileelseiStart=inString(iEnd+1,vbEnter&vbEnter)iEnd=inString(iStart+4,vbEnter&strDiv)if iEnd>iStart thenmFormValue=subString(iStart+4,iEnd-iStart-4)elsemFormValue=""end ifform.Add mFormName,mFormValueend ifiFormStart=iformEnd+iDivLeniFormEnd=inString(iformStart,strDiv)-1wendEnd SubPrivate Function subString(theStart,theLen)dim i,c,stempupfile_5xSoft_Stream.Position=theStart-1stemp=""for i=1 to theLenif upfile_5xSoft_Stream.EOS then Exit forc=ascB(upfile_5xSoft_Stream.Read(1))If c > 127 Thenif upfile_5xSoft_Stream.EOS then Exit forstemp=stemp&Chr(AscW(ChrB(AscB(upfile_5xSoft_Stream.Read(1)))&ChrB(c)))i=i+1elsestemp=stemp&Chr(c)End IfNextsubString=stempEnd functionPrivate Function inString(theStart,varStr)dim i,j,bt,theLen,strInString=0Str=toByte(varStr)theLen=LenB(Str)for i=theStart to upfile_5xSoft_Stream.Size-theLenif i>upfile_5xSoft_Stream.size then exit Functionupfile_5xSoft_Stream.Position=i-1if AscB(upfile_5xSoft_Stream.Read(1))=AscB(midB(Str,1)) thenInString=ifor j=2 to theLenif upfile_5xSoft_Stream.EOS theninString=0Exit forend ifif AscB(upfile_5xSoft_Stream.Read(1))<>AscB(MidB(Str,j,1)) thenInString=0Exit Forend ifnextif InString<>0 then Exit Functionend ifnextEnd FunctionPrivate Sub Class_Terminateform.RemoveAllfile.RemoveAllset form=nothingset file=nothingupfile_5xSoft_Stream.closeset upfile_5xSoft_Stream=nothingEnd SubPrivate function GetFilePath(FullPath)If FullPath <> "" ThenGetFilePath = left(FullPath,InStrRev(FullPath, ""))ElseGetFilePath = ""End IfEnd functionPrivate function GetFileName(FullPath)If FullPath <> "" ThenGetFileName = mid(FullPath,InStrRev(FullPath, "")+1)ElseGetFileName = ""End IfEnd functionPrivate function toByte(Str)dim i,iCode,c,iLow,iHightoByte=""For i=1 To Len(Str)c=mid(Str,i,1)iCode =Asc(c)If iCode<0 Then iCode = iCode + 65535If iCode>255 TheniLow = Left(Hex(Asc(c)),2)iHigh =Right(Hex(Asc(c)),2)toByte = toByte & chrB("&H"&iLow) & chrB("&H"&iHigh)ElsetoByte = toByte & chrB(AscB(c))End IfNextEnd functionEnd ClassClass FileInfodim FormName,FileName,FilePath,FileSize,FileStartPrivate Sub Class_InitializeFileName = ""FilePath = ""FileSize = 0FileStart= 0FormName = ""End SubP
Asp生成xml乱码解放方法
<!--#include file="../inc/conn.asp"--><%Call opendata(1)Set rs=server.CreateObject("adodb.recordset")xmlfile=server.mappath("content.xml")Set fso = CreateObject("Scripting.FileSystemObject")Set MyFile = fso.CreateTextFile(xmlfile,True,-1)MyFile.WriteLine("<?xml version=""1.0"" encoding=""utf-8"" standalone=""yes""?>")MyFile.WriteLine("<content Name=""新闻动态"">")rs.open "select * from detail where classid=268 order by updatetime desc",conn,1,1if not rs.eof thendo while not rs.eof MyFile.WriteLine("<article Thumb=""news/thumb4.jpg"" Large =""news/large4.jpg"">") MyFile.WriteLine("<headline>xx竹立方竹艺臻品馆开馆</headline>") MyFile.WriteLine("<date>2010/05/01</date>") MyFile.WriteLine("<copy_intro><![CDATA[竹立方,来自竹林深处的清新气息,来自时代低碳环保的呼唤,来自健康时尚的现代生活理念。]]></copy_intro>") MyFile.WriteLine("<copy_full><![CDATA[    竹立方,来自竹林深处的清新气息,来自时代低碳环保的呼唤,来自健康时尚的现代生活理念。<br><br>    竹立方——竹艺臻品馆,主要经营竹炭、竹纤维、竹家具、竹工艺品等,与最具实力的厂家合作,提供一手货源,为广大追求现代都市时尚生活的人提供低碳环保的竹产品。<br><br>     一想到竹,便想到那份翠绿。竹子,从竹竿,竹笋到竹纤维,竹地板,竹炭,从以其虚心谦恭的品格,默默无闻地做出贡献。而其独特的品质,自身的特性,发展前景不可限量。<br><br>    来竹立方,感受竹子带来的那份美妙神奇吧!]]></copy_full>") MyFile.WriteLine("<copy_pic><![CDATA[竹立方]]></copy_pic>") MyFile.WriteLine("</article>")rs.movenextloopend ifrs.closeMyFile.WriteLine("</content>")MyFile.Close%>  最近研究asp生成xml文件,发现如果生成文件里面出现中文的话,xml文件就是乱码。在网上找了一下,说的都是把页面,xml都设置成统一的编码等等,但是都没有解决问题。原因:后来发现原来是fso的问题:fso不支持utf-8。解决办法:Set MyFile = fso.CreateTextFile(xmlfile,True,-1)  这句的第三个参数就非常重要-1是boolean值的true; 拓展:下面是对CreateTextFile的参数的详细说明:object.CreateTextFile(filename[, overwrite[, unicode]])参数object必选项。应为 FileSystemObject 或 Folder 对象的名称。filename必选项。指明所要创建文件的字符串表达式。overwrite可选项。Boolean 值,指明能否覆盖已有文件。如果文件可以覆盖,则值为 true ,否则为 false。如果忽略,则已有文件不能被覆盖。unicode可选项。Boolean 值,指明文件是否以 Unicode 或 ASCII 文件方式创建。如果文件作为 Unicode 文件创建,则值为 true ,如果作为 ASCII 文件创建,则为 false。如果忽略,则假定为 ASCII 文件。 范例代码:<%xmlfile=server.mappath("media.xml")Set fso = CreateObject("Scripting.FileSystemObject")Set MyFile = fso.CreateTextFile(xmlfile,True,-1)MyFile.WriteLine("<?xml version=""1.0"" encoding=""UTF" & "-8""?>")MyFile.WriteLine("<settings autoRotate=""1"" autoRotateSpeed=""4""  useSubtitle=""0"" useTooltip=""1""   useSecondCaption=""1""   spanX=""400""  spanY=""40""  centerX=""500"" centerY=""300""  distanceValue=""0""  perspectiveRatio=""0.5""  minimumscale="".1"" turningspeed=""4""  rotationKind=""1""  useFocalBlur=""1""  focalBlurValue="".6""  useMotionBlur=""1""   motionBlurValue="".25""  useFadeOnMouseOver=""1""  mouseOverAlphaValue="".5"" useReflection=""1""   reflectionAlphaValue="".5""")MyFile.WriteLine(" />")%><%MyFile.WriteLine("<photos>")%><%MyFile.WriteLine("<photo imageURL=""空调打孔"" linkData=""http://www.kongtiaodakong.com/"" linkType=""frameNumber"" linkTarget=""carousel"" captionText=""陈瑞"" captionText2=""陈瑞"" enableButtonWhenInFront=""1"" />")%><%MyFile.WriteLine("</photos>")%><%MyFile.Close%> 
IIS出现server application error的解决办法
Server Application ErrorThe server has encountered an error while loading2009-10-31 14:48The server has encountered an error while loading an application during the processing of your request. Please refer to the event log for more detail information. Please contact the server administrator for assistance.iis 5.1出现上面的错误。解决方案:(只讲解决办法,不讲原理,想知道原理,请百度一下。本文修改自网络上的一篇文章,适合网络菜鸟纠正错误。谨向原作者致敬。)办法分三步走:(注:文中的数字:1234表示你要设置的密码。)一:    1。右键我的电脑--管理--系统工具--本地用户和组-用户,给“IUSR_机器名” 和 “IWAM_机器名” 两个用户设置密码(我设置为1234),要一样。(设置密码的操作为鼠标右击,选择设置密码)2。开始--运行--打cmd,然后  cd c:\Inetpub\AdminScripts然后  cscript.exe adsutil.vbs set w3svc/wamuserpass "1234"然后  cscript.exe adsutil.vbs set w3svc/anonymoususerpass "1234"   然后  cscript.exe synciwam.vbs -v最后  重启iis。测试一下网页,搞定了的话,恭喜你!!!没搞定的也不要气馁,继续下面的操作(可能在你的最下面一行出现 8004e00f错误,那是因为MSDTC服务不正常造成)二、1、删除注册表中的键:· HKEY_LOCAL_MACHINE/SYSTEM/Current Control/Set Services MSDTC· HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/MSDTC· HKEY_CLASSES_ROOT/CID2、开始-运行-cmd,然后依次执行下面的三个命令        停止MSDTC服务:net stop msdtc  卸载MSDTC服务:msdtc -uninstall   重新安装MSDTC服务:msdtc -install3、开始-运行-eventvwr,打开事件查看器,点击“应用程序”选项,在右边的窗口上点击最上面的一条信息,查看内容,确认在事件查看器中msdtc服务已经正常启动[这步很关键,如果没有,重新启动下电脑看看]4、再依次执行一下第一大部分的命令。到这部分网上大部分都说可以了,但是我这里虽然没有8004e00f的错误提示了,但是访问页面Server Application Error 错误依旧,于是继续。三、[1]:检查你的DTC服务(全名:Distributed Transaction Coordinator)是否可以正常启动,如果正常的话请你跳过此步骤;如果出错,无法正常启动,请在开始菜单的运行中 运行:msdtc -resetlog 以创建日志文件。重起机器,检查IIS是否可以正常使用,若不行继续。[2]:在CMD下执行以下命令:cd %windir%system32inetsrvrundll32 wamreg.dll, CreateIISPackageregsvr32 asptxn.dll(到这里我就可以用了,不用重启的)OK,ASP页面一切正常了。欢呼中。。。