• ASP常用代码


    <!--#include file="inc/Conn.asp"-->

    data_conn="provider=sqloledb;Server=192.168.46.6;Database=edusxzz;UID=sa;PWD=^Y&U*I(O"

    dbPath = "PROVIDER=SQLOLEDB;DATA SOURCE=(local);UID=sa;PWD=;DATABASE=xiongt"

    conn = "Driver={SQL Server};server=.;uid=sa;pwd=^Y&U*I(O;database=edudfrcup"

                            <%

                            set rs=Server.CreateObject("ADODB.Recordset")

    sql="select * from cpzs"

    rs.Open sql,conn,1,3

    if rs.eof then

    response.Write("暂无信息!")

    else

    do while not rs.EOF

           %>

    <li id="active"><a href="prosucts.asp?id=<%=rs("id")%>"><%=rs("title")%></a></li>

                            <%

    rs.MoveNext

    loop

    rs.Close

    set rs=nothing

    end if

    %>

    UpdateTime=re("UpdateTime")

    nUpdateTime = left(nUpdateTime,instr(nUpdateTime," ")-1)

    AddDate=Year(Rs(6))&"-"&Month(Rs(6))&"-"&day(Rs(6))

    文本框不能修改:<input type="text" name="tran_credits" size="10" value="0" maxlength="5" class="InputStyle" disabled="disabled">

    Response.Write("<script>alert('用户名或密码不能为空!');location='index.asp';</script>")

    图像提交按钮<input type="image" name="00" src="images/search_btn.jpg" width="51" height="20" />

                <input type="submit" name="00" style="background:url(images/search_btn.jpg) no-repeat 0 0; 51px; height:20px; border:0;" value="" />

    update flash5 set cCT=DATEADD('d',-16,cCT) where cct<#22/12/2007#

    update 123 set cCT=DATEADD('d',-15,cCT) where cct between #24/12/2007# and #26/12/2007#

    在Sql SerVer 中没有delete * from zyxz  只有delete  from zyxz

    下拉列表衔接到网址:<select name="page"onchange="location.href=this.options[this.selectedIndex].value;">

      <% for i=1 to total%>

              <option value="index.asp?page=<%=i%>"><%=i%></option>

            <%next%>

          </select>

    <marquee scrollAmount=1 onmouseover=stop() onmouseout=start() width=170 height=200 direction=up></marquee>

    on error resume next

    <input name="strKeyword" id="name" type="text" class="text" value="请输入搜索关键词" onclick="if(this.value=='请输入搜索关键词')this.value=''" onblur="if(this.value=='')this.value='请输入搜索关键词';" />

    <a href="javascript:window.history.back(-1)">返回上一页</a>

    insert into product ([Description]) select [guestcontent] from imgbook

    说明:复制表(只复制结构,源表名:a 新表名:b) 

    SQL: select * into b from a where 1<>1

    <script   language=javascript>alert('系统中不存在该编号(帐号)!'); history.go(-1)</script>

    <script   language="javascript">alert('您的邮箱上没有邮件!');location='javascript:history.back()';</script>

    pop3.Connect   "cw_volcano",   "101010",   "pop.sina.com"  ,"110"

    <A href="javascript:window.external.addFavorite('http://www.langke.com','朗科科技');">加入收藏</A>

    <A onclick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.netac.com.cn');" href="#">设为首页</A>

    strSQL="EXEC sp_CsCustomRecordSearch 0,1,10,'"& ContactRecordIDs & "','" & StartDate& "','" & EndDate & "'"

    中间黑点的代码是&#149;

    <%

    ranNum=int(90000*rnd)+10000

    filename=filepath&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&fileExt

    %>

    Flash底层:<param name="wmode" value="opaque" />

    MD5加密:admin  8D1F1AAC0DD8A76B49E8BBDDA0C7C98C  (8063)

    <div id="del" onclick="javascript:return confirm("你确认删除吗?")">删除</div>

    * html #mainNav { /* hack for ie6 */

    margin-top: 53px;

    }

    *+html #mainNav { /* hack for ie7 */

    margin-top: 53px;

    }

    特别值得注意的是,如果源文件头部没有DTD声明或者声明不正确,ie7会采取quirk模式,* html招数将起作用;只用在DTD声明正确的情况下,*+html招数对ie7才有用,同时* html在ie7中失效。

    asp使用存储过程:strSQL="EXEC sp_CsCustomRecordSearch 0,1,10,'"& ContactRecordIDs & "','" & StartDate& "','" & EndDate & "'"

    conn.execute("exec SP_Examination "&s_all(i)&"") 

    获取IP地址  IP=request.ServerVariables("REMOTE_HOST")

     <iframe src="" width="100%" height="100%" marginheight=0 frameborder=0 topmargin=0 leftmargin=0></iframe>

    SQLSERVER中的变量类型转换:CAST(@RecsPerPage AS VARCHAR(20))

    user_ip = Request.ServerVariables("REMOTE_ADDR")

    regsvr32   组件路径   //可以注册   

    regsvr32   组件路径   -u   //删除已注册的组件

    返回值函数:

    function group(fid)

    set rs1=Server.CreateObject("ADODB.Recordset")

    set rs1=conn.execute("select user_group_id from user_group where per_user_group="&fid&" ")

    if not rs1.eof then

    do while not rs1.eof

    group=group&rs1(0)&","

    call group(rs1(0)) '递归子级分类

    rs1.movenext

    if rs1.eof then

    rs1.close

    exit function

    end if

    loop

    end if

    end function

    ASP中用到数组:

    Function Getnamebyids(ids)

    nums=split(ids,",")

    for s=0 to UBound(nums)

    opendb()

    set rs=Server.CreateObject("ADODB.Recordset")

    sql="select * from optionname where O_id="&nums(s)

    rs.Open sql,dbconn,1,3

    Getnamebyids=Getnamebyids&rs("optionname")&","

    rs.Close

    set rs=nothing

    CloseDB()

    next

    End Function

    conn.CommandTimeout=2400

    Server.ScriptTimeOut=90000000 

    ASP导出Excel:

    Response.Buffer   =   TRUE   

    Response.AddHeader   "Content-Disposition",   "attachment"   

    Response.contentType="application/vnd.ms-excel"   

    跳转到当前页面的上一页:

    fh=request.servervariables("http_referer")   

    response.redirect(fh)

    利用iframe实现页面局部刷新:

    1.<iframe src="merchant_info.asp" width="696" marginwidth="0" height="128" marginheight="0" align="left" scrolling="auto" frameborder="0" name="mv"></iframe>

    2.<a href="pic.asp?id=<%=rs("id")%>" target="mv">

    select case tid

     case "83": i="工程纸系列"

     case "134": i="家装纸系列"

    end select 

    if(document.forma.Email.value.length!=0)

    {

    if (document.forma.Email.value.charAt(0)=="." ||        

    document.forma.Email.value.charAt(0)=="@"||       

    document.forma.Email.value.indexOf('@', 0) == -1 || 

    document.forma.Email.value.indexOf('.', 0) == -1 || 

    document.forma.Email.value.lastIndexOf("@")==document.forma.Email.value.length-1 || 

    document.forma.Email.value.lastIndexOf(".")==document.forma.Email.value.length-1)

    {

    alert("邮箱格式错误!");

    document.forma.Email.focus();

    return false;

    }

    }

    验证单选按钮组:

    var RValue=GetRadioValue("radiobutton");

      function GetRadioValue(RadioName){

        var obj=document.getElementsByName(RadioName);

        if(obj!=null){

            var i;

            for(i=0;i<obj.length;i++){

                if(obj[i].checked){

                    return obj[i].value;            

                }

            }

        }

        return null;

    }

    if(RValue==null){

    alert("请选择会员类别!");

    return false;

    }

    <%scriptName = request.ServerVariables("SCRIPT_NAME")%>

    class="<%if instr(scriptName,"cpsc") > 0 then%>current<%else%><%end if%>"

  • 相关阅读:
    provider: Shared Memory Provider, error: 0
    用户 'sa' 登录失败。 (Microsoft SQL Server,错误: 18456)
    从sqlite 迁移到mysql报错,处理 D:seafile-server_5.0.3_win32seafile-server-5.0.3seahubsql 重新执行这个SQL
    org.apache.jasper.runtime.ELContextImpl cannot be cast to org.apache.jasper.el.ELContextImpl
    java.lang.NoClassDefFoundError: org/apache/log4j/spi/ThrowableInformation
    无法完成操作。服务无法在此时接受控制信息。
    MyEclipse出现Unable to install breakpoint in...
    ERROR 1364 (HY000): Field 'id' doesn't have a default value
    各地都在搞大数据,你的家乡有啥特色没——解读2017年地方政府大数据报告
    HTML5桌面通知:notification
  • 原文地址:https://www.cnblogs.com/cw_volcano/p/1947517.html
Copyright © 2020-2023  润新知