asp Access数据备份,还原,压缩类代码

发布时间:2022-04-17 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了asp Access数据备份,还原,压缩类代码脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
<!--#include file="config.asp" -->
<!--#include file="Fun.asp" -->
<%
'数据库管理类
class Datas
'备份
public sub Bk()
Set fso=server.createobject("scripting.fileSystemobject")
fso.CopyFile Server.MapPath(SITeDataPath),Server.MapPath(SiteDataBakPath)
&nbsp;    set fso=nothing
response.Write("<script language=javascript><!--
alert('备份成功!');window.location.href='Datamanage.asp'
// --></script>")
end sub

'还原
    public sub Rt()
     SDPath = server.mappath(SiteDataPath)
SDBPath = server.mappath(SiteDataBakPath)
     set Fso=Server.CreateObject("Scripting.FileSystemObject")
if Fso.FileExists(SDBPath) then
Fso.CopyFile SDBPath,SDPath
Set Fso=nothing
         response.Write("<script language=javascript><!--
alert('成功:你已经成功恢复数据库!');window.location.href='DataManage.asp?action=rt'
// --></script>")
else
         response.Write("<script language=javascript><!--
alert('失败:请检查路径和数据库名是否存在');window.location.href='DataManage.asp?action=rt'
// --></script>")
end if
    end sub

    '压缩
    public sub Dc()
     SDBPath = server.mappath(SiteDataBakPath)
     set Fso=Server.CreateObject("Scripting.FileSystemObject")
     if Fso.FileExists(SDBPath) then
Set Engine =Server.CreateObject("JRO.JetEngine")
     if request("boolIs") = "97" then
     Engine.COMpactDatabase "PRovider=Microsoft.Jet.OLEDB.4.0;Data Source=" & SDBPath, _
         "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & SDBPath & "_temp.mdb;" _
         & "Jet OLEDB:Engine TyPE=" & JET_3X
     else
     Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & SDBPath, _
         "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & SDBPath & "_temp.mdb"
end if
Fso.CopyFile SDBPath & "_temp.mdb",SDBPath
Fso.DeleteFile(SDBPath & "_temp.mdb")
set Fso = nothing
set Engine = nothing
     response.Write("<script language=javascript><!--
alert('成功:数据库已经压缩成功!');window.location.href='DataManage.asp?action=dc'
// --></script>")
else
     response.Write("<script language=javascript><!--
alert('失败:数据库压缩失败,请检查路径和数据库名是否存在!');window.location.href='DataManage.asp?action=dc'
// --></script>")
end if
    end sub     
end class
%>

脚本宝典总结

以上是脚本宝典为你收集整理的asp Access数据备份,还原,压缩类代码全部内容,希望文章能够帮你解决asp Access数据备份,还原,压缩类代码所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。