当前位置: 首页 > 图文教程 > 网络编程 > ASP > 无组件的数据库的备份与还原

ASP
ASP调用ORACLE存储过程并返回结果集
用ASP实现网页BBS
关于Global.asa文件的深入研究与session变量失效提示的具体方法
简易ASP+注册系统
防护手册:如何防止ASP木马在服务器上运行
用Visual Basic实现多画面播放功能之二
如何增强ASP程序性能(1)
如何增强ASP程序性能(2)
如何增强ASP程序性能(3)
ASP备份数据库
二十八条改善 ASP 性能和外观的技巧
在Form域中Post大于100K的数据
如何使用ASP制作模似动态生长的表单?
Microsoft IIS 真的如此「不安全」吗?(1)
Microsoft IIS 真的如此「不安全」吗?(2)
Microsoft IIS 真的如此「不安全」吗?(3)
Microsoft IIS 真的如此「不安全」吗?(4)
Microsoft IIS 真的如此「不安全」吗?(5)
关于页面和代码分离
ServerVariables 对路径的操作

ASP 中的 无组件的数据库的备份与还原


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 98 ::
收藏到网摘: n/a

 

看过数据库的备份与还原。大多数都是用组件来完成的。其实可通过sql语句来完成。
由于时间关系,未对参数进行验证和界面美化。代码仅供参考。
共计4个文件:下载地址:http://ad.ceh.com.cn/sql.rar
conn.asp
<%
conn="Provider=SQLOLEDB.1;Persist Security Info=false;Server=127.0.0.1;UID=sa;pwd=www.zhi.net;database=master"
function rec(rs,sql)
set rs = server.CreateObject("ADODB.Recordset")
rs.Activeconnection = conn
rs.Source = sql
rs.CursorType = 0
rs.Cursorlocation = 3
rs.LockType = 1
rs.Open
if rs.eof and rs.bof then
rec= false
else
rec= true
end if
end function
function cmd(sql)
dim cmd1
set cmd1 = server.CreateObject("ADODB.Command")
cmd1.ActiveConnection = conn
cmd1.CommandText = sql
cmd1.CommandType = 1
cmd1.CommandTimeout = 0
cmd1.Prepared = true
cmd1.Execute()
end function
function cdb(rs)
rs.close()
set rs=nothing
end function
%>
dev.asp
<!--#include file="conn.asp"-->
 <%
 if request("AddDev") <> "" then
sql="select name,phyname from master..sysdevices where status=16 and name='"&request("devname")&"'"
rec chk,sql
if chk.eof and chk.bof then
sql = "sp_addumpdevice 'disk','"&request("devname")&"','"&request("phyname")&"'"
cmd sql
response.Write "<script language=javascript>window.location=reload;</script>"
else
response.Write "<script language=javascript>alert('数据库中已存在"&request("devname")&"设备!');window.location='cmd.asp';</script>"
end if
end if
if request("deldev") <> "" then
sql = "sp_dropdevice '"&request("devname")&"'"
cmd sql
response.Write "<script language=javascript>window.location=reload;</script>"
end if
 rec li,"select name,phyname from master..sysdevices where status=16"
 if li.eof and li.bof then
 response.Write "<font color=#ff0000>请新建备份设备用来备份还原数据库</font>"
 else
 %><style type="text/css">
<!--
body {
 margin-left: 0px;
 margin-top: 0px;
}
-->
</style>
<table width="60%"  border="0" cellspacing="0">
  <tr>
    <td width="29%">名称:</td>
    <td width="71%">位置:</td>
  </tr>
  <%
  i=0
  while not li.eof
  i=i+1
  %>
  <tr>
    <td><%=li(0)%></td>
    <td><%=li(1)%> <a href='dev.asp?DelDev=1&devname=<%=li(0)%>'>删除此设备</a></td>
  </tr>
  <%
  li.movenext
  wend
  response.Write "<script language=javascript>top.document.all.dev.height='"&(i+1)*25&"';</script>"
   cdb li
  %>
</table>
<%
end if
%>
default.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp"-->
<%
'*************************************************
'数据库备份与还原
'编        程:魔术师·杨(MagicYang.CN)
'完成日期:2004-4-11
'说明:由于时间关系,未对数据做安全性验证。
'应用时请对数据进行验证,确保安全。
'QQ:1168064  欢迎大家互相交流
'*************************************************
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>数据库的备份与还原</title>
</head>

<body>
<%

%>
<table width="80%"  border="0" align="center">
  <tr>
    <td width="21%" valign="top">数据库设备:</td>
    <td width="79%">
<iframe name="dev" src="dev.asp" width="1"