博文

数据库连接(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......

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

只许输入文字的文本区域(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>......

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

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......

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

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")%>......

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

智能计算器(2006-04-17 10:41:00)

摘要:<html><head><title>智能计算器</title><script language="javascript">function compute_onclick(){ var o=document.form1.input.value; var result=eval(o); document.form1.result.value=result;}</script></head><body><center><form name="form1"><p>请输入表达式&nbsp;<input type="text" name="input"></p><p><input type="button" value="计算" name="compute" onclick="compute_onclick()"></p><p>结果<input type="text" value="" name="result"></p></form></body></html>......

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

两个下拉列表(2006-04-17 10:40:00)

摘要:<script language="javascript">function show(){  for (var i=0;i<document.getElementById("s1").length;i++)  {for (var j=0;j<document.getElementById("s2").length-1;j++)     { document.getElementById("s2").options.remove(j);     }    if (document.getElementById("s1").options[i].selected)       {show1(document.getElementById("s1").options[i].value);         break;       }    }}function show1(v){for (var i=1;i<=v;i++){  document.getElementById("s2").options[i]=new Option(i,i);} document.getElementById("s2").options.remove(0);}</script><select name="s1" onchange="show()" id="s1"><option value="">请选择</option><option value=10>10</option><option value=20>20</option><option value=30>30</option><option value=40>40</option&g......

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

如何得到字符串的每一位?(2006-04-15 16:43:00)

摘要:如何得到字符串的每一位?如:str="123456"a=str的第一位就是1b=str的第二位就是2c=str的第三位就是3…… 解决的方法dim ak()for i=1 to len(XXX) ak(i)=mid(XXX,i,1)next ......

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

常见的ASP代码(2006-04-15 09:38:00)

摘要:1.获得系统时间: <%=now()%> 2.取得来访用的IP: <%=request.serverVariables("remote_host")%> 3.获得系统,浏览器版本: <script> window.document.write("版本:"+navigator.appName+navigator.appVersion+" browser.") </script> 4.去除IE混动条: <body scroll="no">  <body style="overflow-y:hidden"> 5.进入网站,跳出广告: <script language="javascript"> <!--  <!-- 注意更改文件所在路径--> window.open(''http://www.gbunix.com",'''',''height=200,width=300,top=0,left=30''); // --> </script> 6.随机数: <%randomize%> <%=(int(rnd()*n)+1)%> N为可改变数 7.向上混动代码: <marquee direction="up" scrolldelay="200" style="font-size: 9pt; color: #FF0000; line-height: 150%; font-style:italic; font-weight:bold" scrollamount="2" width="206" height="207" bgcolor="#FFFF00">Unix中文站</marquee> 8.自动关闭网页: <script LANGUAGE="javascript"> <!-- setTimeout(''window.close();'', 10000); //60秒后关闭 // --> </script> <p align="center">本页10秒后自动关闭,请注意刷新页面</p......

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

文件区域html格式(2006-04-13 09:28:00)

摘要:这个网页的名字叫:text.asp<% ' 内容提交前用这个函数Function HTMLEncode(fString)'HTML加码函数    If Not IsNull(fString) Then        fString = Replace(fString, CHR(38), "&#38;")        fString = Replace(fString, ">", "&gt;")        fString = Replace(fString, "<", "&lt;")        fString = Replace(fString, CHR(39), "&#39;")        fString = Replace(fString, CHR(32), "&nbsp;")        fString = Replace(fString, CHR(34), "&quot;")        fString = Replace(fString, CHR(13), "")       &nbs......

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