程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> ASP編程 >> 關於ASP編程 >> asp Access數據備份,還原,壓縮類代碼

asp Access數據備份,還原,壓縮類代碼

編輯:關於ASP編程
<!--#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)
     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
%>
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved