ASP Access data backup, restore, compression class implementation code, you can refer to it. <!--#include file=config.asp -->
<!--#include file=Fun.asp -->
<%
'Database management class
class Datas
'Backup
public subBk()
Set fso=server.createobject(scripting.filesystemobject)
fso.CopyFile Server.MapPath(SiteDataPath),Server.MapPath(SiteDataBakPath)
set fso=nothing
response.Write(<script language=javascript><!--
alert('Backup successful!');window.location.href='DataManage.asp'
// --></script>)
end sub
'reduction
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('Success: You have successfully restored the database!');window.location.href='DataManage.asp?action=rt'
// --></script>)
else
response.Write(<script language=javascript><!--
alert('Failure: Please check whether the path and database name exist');window.location.href='DataManage.asp?action=rt'
// --></script>)
end if
end sub
'compression
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('Success: The database has been compressed successfully!');window.location.href='DataManage.asp?action=dc'
// --></script>)
else
response.Write(<script language=javascript><!--
alert('Failure: Database compression failed, please check whether the path and database name exist!'); window.location.href='DataManage.asp?action=dc'
// --></script>)
end if
end sub
end class
%>