Asp常用代码

来源:互联网 发布:数控铣床五角星编程 编辑:程序博客网 时间:2024/04/29 14:51

=============================== 删除 ==================================
  if request("dels")="dels" then
  Set delfile = conn.Execute("select * from [agad] where id="& request("id"))
  on error resume next
  if (IsNull(delfile("upfile")) = false and delfile("upfile") <> "") then
  set fs1 = Server.CreateObject("Scripting.FileSystemObject")
  fs1.deletefile(server.mappath("../"&delfile("upfile")))
  set fs1 = nothing
  end if
  delfile.close
  set delfile=nothing
  sql="delete [agad] where id="&request("id")
  conn.execute sql
  response.Redirect(request.ServerVariables("HTTP_REFERER"))
  end if
=========================== 删除提示 ==================================
<a href="product.asp?dels=dels&id=<%=rs("id")%>" onClick="javascript:if(confirm('您确认此操作吗?')){return true;}else{return false;}">删除</a>

 


=========================== 常用查询代码 ==================================
  set rs=server.CreateObject("adodb.recordset")
  sql="delete from product where id="&id&" ORDER BY ID DESC"
  rs.open sql,conn,3,3

 


========================== 瑞腾数据库查询 =============================
select p.*,c3.fd_pcname,c4.* from tb_products p,tb_productcatalog4 c4,tb_productcatalog3 c3 where p.fd_companyID=11534 and p.fd_pc4ID=c4.fd_pcID and c4.fd_pcupid=c3.fd_pcid and c3.fd_pcid=606 and c3.fd_pcupID=67

 


========================== 图片显示 ===================================
<% if rs("upfile")<>"" or isnull(rs("upfile"))=true then %>
<a href="<%=rs("upfile")%>" target="_blank"><img src="<%=rs("upfile")%>" alt="<%=rs("name")%>" width="100" height="75" border="0" style="background-color: #003366"></a>
<% else %>
<img src="images/none.gif" width="100" height="75">
<% end if %>

 


========================== 会员退出 ================================
if request("exit")="exit" then
response.Expires=-9999
session.Abandon()
response.Redirect("index.asp")
end if

 


=========================== 生成随机数 =================================
Randomize
suis=Int(Rnd()*(9999-1000+1))+1000

 

=========================== 删除、添加、修改图片 =======================
id=getContent("id")
name=getContent("name")
content=getContent("content")
links=getContent("links")
kind=getContent("kind")
if id="" then
sql="insert into [agad](name,content,links,kind,upfile) values('"& name &"','"& content &"','"& links &"','"& kind &"','"& uploadfloder &"/"& fileName &"')"
else
  Set delfile = conn.Execute("select * from [agad] where id="&id)
  on error resume next
  if (IsNull(delfile("upfile")) = false and delfile("upfile") <> "") then
  set fs1 = Server.CreateObject("Scripting.FileSystemObject")
  fs1.deletefile(server.mappath("../"&delfile("upfile")))
  set fs1 = nothing
  end if
  delfile.close
  set delfile=nothing
sql="update [agad] set name='"& name &"',content='"& content &"',links='"& links &"',kind='"& kind &"',upfile='"& uploadfloder &"/"& fileName &"' where id="& id
end if
conn.execute (sql)
response.Redirect("agad.asp?main=main")
response.end

原创粉丝点击