⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bak.asp

📁 自己去看吧ASP的图书馆系统
💻 ASP
字号:
<!--#include file="conn.asp"-->
<%
'if request("do")="bak" then
'dim path
'path=server.MapPath("./")
'response.Write""&path&""

'sql="backup database 谢贵文 to disk='"&path&"\\谢贵文.bak' with init"
'db.execute(sql)
'response.Write"<script>alert('备份成功. 备份文件在目录下');history.go(-1)</script>"
'end if
  if request("do") = "bak" then
    if request("action") = "true" then
	    call backupdata()
		  Response.End
	  end if
%>
  <table class="tableBorder" width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr> 
<td align="center" background="../images/admin_bg_1.gif"><b><font color="#ffffff">备份数据库</font></b></td>
</tr>
<tr>
<td width="100%" >
<font color="#FF0000">注意:注意:备份数据需要FSO组件支持,FSO组件的相关帮助!所有路径都是相对与程序空间根目录的相对路径!此功能谨慎使用,可能在有些空间备份后,在本机上不能用ACCESS打开。</font></td>
</tr>
<tr><form method="post" action="bak.asp?do=bak&action=true">
<td width="100%" >
当前数据库路径:<input type=text size=24 name=DBpath value="book.mdb"> 
请正确添写您当前使用的数据库路径!<BR>
备份数据库目录:<input type=text size=24 name=bkfolder value=Databackup>
如果目录不存在,程序将自动创建!<BR>
备份数据库名称:<input type=text size=24 name=bkDBname value=book.mdb>
如果备份目录有该文件,将覆盖,如果没有,程序将自动创建!<br>
<input type=submit value="开始备份"></td>
</tr>
<tr>
<td width="100%" >
在上面填写数据库路径及数据库完整名称,程序的默认数据库文件为book.mdb<br>
您可以用这个功能来备份您的数据库,以保证数据的安全!<br></td>
</tr></form>
</table>
<%
  end if
%>

<%
  'if request("do")="restore" then
'判断悲愤文件是否存在
'set iFso=server.CreateObject("Scripting.FileSystemObject")'FSO组件
'dim bak_path
'bak_path=server.MapPath("./谢贵文.bak")
'if not iFso.FileExists(bak_path) then
'response.Write"<script>alert('备份文件不存在');history.go(-1)</script>"
'else
'sql1="use master"'获得派他访问权 短开与当前系统数据的连接
'sql="restore database 谢贵文 from disk='"&server.MapPath("./")&"\\谢贵文.bak' "
'db.execute(sql1)
'db.execute(sql)
'response.Write"<script>alert('还原成功.');history.go(-1)</script>"
'end if
'end if'页面history.go(-1)时自己会重新连接数据库
if request("do") = "restore" then
  if request("action") = "true" then
    call restoredata()
	  Response.End
	end if
%>
 <table class="tableBorder" width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr> 
<td align="center" background="../images/admin_bg_1.gif"><b><font color="#ffffff">还原数据库</font></b></td>
</tr>
<tr>
<td width="100%" >
<font color="#FF0000">注意:注意:还原数据需要FSO组件支持,FSO组件的相关帮助!所有路径都是相对与程序空间根目录的相对路径!此功能谨慎使用,可能在有些空间还原后,在本机上不能用ACCESS打开。</font></td>
</tr>
<tr><form method="post" action="bak.asp?do=restore&action=true">
<td width="100%" >
还原数据库目录:<input type=text size=24 name=bkfolder value=Databackup>
如果目录不存在,程序将自动创建!<BR>
还原数据库名称:<input type=text size=24 name=bkDBname value=book.mdb>
如果还原目录有该文件,将覆盖,如果没有,程序将自动创建!<br>
数据库路径:<input type=text size=24 name=DBpath value="book.mdb"> 
请正确添写您当前使用的数据库路径!<BR>
<input type=submit value="开始还原"></td>
</tr>
<tr>
<td width="100%" >
在上面填写数据库路径及数据库完整名称,程序的默认数据库文件为book.mdb<br>
您可以用这个功能来备份您的数据库,以保证数据的安全!<br></td>
</tr></form>
</table>
<%
end if
%>

<%
sub restoredata()
  Dbpath=request.form("Dbpath")
  Dbpath=server.mappath(Dbpath)
  bkfolder=request.form("bkfolder")
  bkdbname=request.form("bkdbname")
  Set Fso=server.createobject("scripting.filesystemobject")
  'if fso.fileexists(dbpath) then
    If CheckDir(bkfolder) = True Then
      fso.copyfile bkfolder& "\"& bkdbname,dbpath
    else
      MakeNewsDir bkfolder
		  fso.copyfile bkfolder& "\"& bkdbnamed,bpath
	  end if
    response.write "<script>alert('数据库还原完成,请进行其他操作!')</script>"
  'else
   ' response.write "找不到您所需要备份的文件!"
  'end if
end sub

sub backupdata()
  Dbpath=request.form("Dbpath")
  Dbpath=server.mappath(Dbpath)
  bkfolder=request.form("bkfolder")
  bkdbname=request.form("bkdbname")
  Set Fso=server.createobject("scripting.filesystemobject")
  if fso.fileexists(dbpath) then
    If CheckDir(bkfolder) = True Then
      fso.copyfile dbpath,bkfolder& "\"& bkdbname
    else
      MakeNewsDir bkfolder
		  fso.copyfile dbpath,bkfolder& "\"& bkdbname
	  end if
    response.write "<script>alert('数据库备份完成,请进行其他操作!')</script>"
  else
    response.write "找不到您所需要备份的文件!"
  end if
end sub

Function CheckDir(FolderPath)
  folderpath=Server.MapPath(".")&"\"&folderpath
  Set fso1 = CreateObject("Scripting.FileSystemObject")
  If fso1.FolderExists(FolderPath) then
    CheckDir = True
  Else
    CheckDir = False
	End if
  Set fso1 = nothing
End Function

Function MakeNewsDir(foldername)
Set fso1 = CreateObject("Scripting.FileSystemObject")
Set f = fso1.CreateFolder(foldername)
MakeNewsDir = True
Set fso1 = nothing
End Function

%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -