博文
ASP编程中15个非常有用的例子(2006-05-27 11:57:00)
摘要:ASP编程中15个非常有用的例子
1.如何用Asp判断你的网站的虚拟物理路径?
答 使用Mappath方法
<p align="center"><font size="4" face="Arial"><b>
The Physical path to this virtual website is:
</b></font>
<font color="#FF0000" size="6" face="Arial">
<%= Server.MapPath("\")%>
</font></p>
2.我如何知道使用者所用的浏览器?
答 使用the Request object方法
strBrowser=Request.ServerVariables("HTTP_USER_AGENT")
If Instr(strBrowser,"MSIE") <> 0 Then
Response.redirect("ForMSIEOnly.htm")
Else
Response.redirect("ForAll.htm")
End If
3。如何计算每天的平均反复访问人数?
答 解决方法
<% startdate=DateDiff("d",Now,"01/01/1990")
if strdate<0 then startdate=startdate*-1
avgvpd=Int((usercnt)/startdate) %>
显示结果
<% response.write(avgvpd) %>
that is it.this page have been viewed since November 10,1998
4 如何显示随机图象?
<% dim p,ppic,dpic
ppic=12
randomize
p=Int((ppic*rnd)+1)
dpic="graphix/randompics/"&p&".gif"
%>
显示
<img src="<%=dpic%>>">
5.如何回到先前的页面?
答<a href=......
通用分页代码(2006-05-27 11:47:00)
摘要:<% dim rs,sql,i
filePath = Server.MapPath("66.mdb") Set oConn = Server.CreateObject("ADODB.Connection") oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & filePath
set rs =Server.CreateObject("adodb.recordset") sql="select * from info order by id" rs.open sql,oConn,1,1%><% rs.pagesize=20 page=clng(Request("page")) if page<1 then page=1 if page>rs.pagecount then page=rs.pagecount rs.AbsolutePage = page%><table width="620" border="0"> <% for i=1 to rs.pagesize %> <tr> <td width="128" valign="top"><% response.write rs("tel") %></td> <td width="482"><% respo......
asp错误提示(2006-05-27 11:41:00)
摘要:asp错误提示
MicrosoftVBScript语*错误(0x800A03E9)-->内存不足MicrosoftVBScript语*错误(0x800A03EA)-->语*错误MicrosoftVBScript语*错误(0x800A03EB)-->缺少 ':'MicrosoftVBScript语*错误(0x800A03ED)-->缺少 '('MicrosoftVBScript语*错误(0x800A03EE)-->缺少 ')'MicrosoftVBScript语*错误(0x800A03EF)-->缺少 ']'MicrosoftVBScript语*错误(0x800A03F2)-->缺少标识符MicrosoftVBScript语*错误(0x800A03F3)-->缺少 '='MicrosoftVBScript语*错误(0x800A03F4)-->缺少 'If'MicrosoftVBScript语*错误(0x800A03F5)-->缺少 'To'MicrosoftVBScript语*错误(0x800A03F6)-->缺少 'End'MicrosoftVBScript语*错误(0x800A03F7)-->缺少 'Function'MicrosoftVBScript语*错误(0x800A03F8)-->缺少 'Sub'MicrosoftVBScript语*错误(0x800A03F9)-->缺少 'Then'MicrosoftVBScript语*错误(0x800A03FA)-->缺少 'Wend'MicrosoftVBScript语*错误(0x800A03FB)-->缺少 'Loop'MicrosoftVBScript语*错误(0x800A03FC)-->缺少 'Next'MicrosoftVBScript语*错误(0x800A03FD)-->缺少 'Case'MicrosoftVBScript语*错误(0x800A03FE)-->缺少 'Select'MicrosoftVBScript语*错误(0x800A03FF)-->缺少表达式MicrosoftVBScript语*错误(0x800A0400)-->缺少语句MicrosoftVBScript语*错误......
c语言画蜡烛(2006-05-20 17:00:00)
摘要:#include<stdlib.h>#include<stdio.h>#include<graphics.h>int main(){ int gdriver=VGA, gmode=VGAHI, i,j,size,s2,s3,s4; initgraph(&gdriver, &gmode, "c:\\tc"); setbkcolor(BLUE); cleardevice(); setcolor(12); setfillstyle( 4,4) ; bar(180,360,200,320); /*蜡烛*/ sector(190,310,0,360,4,6); setcolor(6); getch(); closegraph();}......
asp生成静态页面方法一(2006-05-17 14:43:00)
摘要:首先,模板需要在线修改,则应采用数据库保存模板代码
所谓的模板,就是设计完工的标准的HTML代码,其中需要由程序实现的功能部分将采用特殊字符串代替。然,这些特殊字符串需要在显示的时候被编译为对应的功能。
1,设计数据库testmb.mdb 新建表moban:字段m_id(自动编号,主关键字);字段m_html(备注类型)
2,假设第一模板内容代码
将下列代码拷贝到m_html字段中 以下是代码片段: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>testmb</title> </head> <body leftmargin="0" topmargin="0"> <table width="100%" height="100%" border="0" cellpadding="5" cellspacing="2"> <tr align="right" bgcolor="#CCCCCC"> <td height="20" colspan="2">$cntop$</td> </tr> <tr valign="top"> <td width="25%" bgcolor="#e5e5e5">$cnleft$</td> <td width="74%" bgcolor="#f3f3f3">$cnright$</td> </tr> </table> </body> </html> 注意$cntop$、$cnleft$、$cnright$,它们将要实现某些具体的程序功能
3,建立数据库连接文件conn.......
数据库连接(2006-04-30 14:02:00)
摘要:1. ASP与Access数据库连接: <% dim conn,mdbfile mdbfile=server.mappath("数据库名称.mdb") set conn=server.createobject("adodb.connection") conn.open "driver={microsoft access driver (*.mdb)};uid=admin;pwd=数据库密码;dbq="&mdbfile %> 2. ASP与SQL数据库连接: <% dim conn set conn=server.createobject("ADODB.connection") con.open "PROVIDER=SQLOLEDB;DATA SOURCE=SQL服务器名称或IP地址;UID=sa;PWD=数据库密码;DATABASE=数据库名称 %> 建立记录集对象: set rs=server.createobject("adodb.recordset") rs.open SQL语句,conn,3,2 3. SQL常用命令使用方法: (1) 数据记录筛选: sql="select * from 数据表 where 字段名=字段值 order by 字段名 " sql="select * from 数据表 where 字段名 like ‘%字段值%‘ order by 字段名 " sql="select top 10 * from 数据表 where 字段名 orde......
只许输入文字的文本区域(2006-04-28 09:34:00)
摘要:<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>无标题文档</title></head>
<body><form name="form1" method="post" action=""> <div align="center"> <input onkeyup="value=value.replace(/[^\u4E00-\u9FA5]/g,'')" name="textfield" type="text" value="1"> </div></form></body></html>......
正则的教程和文章(2006-04-27 09:06:00)
摘要:
\ 将下一个字符标记为一个特殊字符、或一个原义字符、或一个 向后引用、或一个八进制转义符。例如,'n' 匹配字符 "n"。'\n' 匹配一个换行符。序列 '\\' 匹配 "\" 而 "\(" 则匹配 "("。 ^ 匹配输入字符串的开始位置。如果设置了 RegExp 对象的 Multiline 属性,^ 也匹配 '\n' 或 '\r' 之后的位置。 $ 匹配输入字符串的结束位置。如果设置了RegExp 对象的 Multiline 属性,$ 也匹配 '\n' 或 '\r' 之前的位置。 * 匹配前面的子表达式零次或多次。例如,zo* 能匹配 "z" 以及 "zoo"。* 等价于{0,}。 + 匹配前面的子表达式一次或多次。例如,'zo+' 能匹配 "zo" 以及 "zoo",但不能匹配 "z"。+ 等价于 {1,}。 ? 匹配前面的子表达式零次或一次。例如,"do(es)?" 可以匹配 "do" 或 "does" 中的"do" 。? 等价于 {0,1}。 {n} n 是一个非负整数。匹配确定的 n 次。例如,'o{2}' 不能匹配 "Bob" 中的 'o',但是能匹配 "food" 中的两个 o。 {n,} n 是一个非负整数。至少匹配n 次。例如,'o{2,}' 不能匹配 "Bob" 中的 'o',但能匹配 "foooood" 中的所有 o。'o{1,......
asp常用函数(2006-04-24 08:55:00)
摘要:
1.函数array() 功能:创建一个数组变量 格式:array(list) 参数:list 为数组变量中的每个数值列,中间用逗号间隔 例子: <% i = array ("1","2","3") %> 结果: i 被赋予为数组 2.函数Cint() 功能:将一表达式/其它类型的变量转换成整数类型(int) 格式:Cint(expression) 参数:expression 是任何有效的表达式/其它类型的变量 例子: <% f = "234" response.write cINT(f) + 2 %> 结果: 236 函数Cint()将字符"234"转换 成整数234.如果表达式为空, 或者无效时,返回值为0; 3.函数:Creatobject() 功能:创建及返回一个ActiveX对象. 格式:Creatobject(obname) 参数bname 是对象的名称 例子: <% Set con = Server.CreateObject("ADODB.Connection") %> 结果: 4.函数Cstr() 功能:将一表达式/其它类型的变量转换成字符类型(string) 格式:Cstr(expression) 参数:expression是任何有效的表达式/其它类型的变量 例子: <% s = 3 + 2 response.write "The result is: " & cStr(s) %> 结果:函数Cstr()将整数 5 转换 成字符"5". 5.函数Date() 功能:返回当前系统(server端)的日期 格式: Date() 参数:无 例子<% date () %> 结果:05/10/00 6.函数Dateadd() 功能:计算某个指定的时间和 格式: dateadd(timeinterval,number,date) 参数:timeinterval是时间单位(月,日..); number是时间间隔值,date是时间始点. 例子: <% currentDate = #8/4/99# newDate = DateAdd("m",3,currentDate) response.write newDate %> <% currentDate = #1......
file与text共存(2006-04-18 17:28:00)
摘要:网页一:
<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>无标题文档</title></head>
<body><form action='2.asp' method='post'> <p> <input type='file' name='upfilename'> </p> <p> <input name="text1" type="text" id="text1"> </p> <p> <input type='submit'> </p></form></body></html>
网页二:2.asp
<% Function GetFileName(ByVal strFile) If strFile <> "" Then GetFileName = mid(strFile,InStrRev(strFile, "\")+1) Else GetFileName = "" End If End function strFileName = Request.Form("upfilename") If strFileName<>"" Then response.Write(getfilename(strfilename)) end if response.write request.Form("text1")%>......
