asp Access数据备份,还原,压缩类代码
更新时间:2009年11月29日 22:34:28 作者:
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)
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
%>
<!--#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
%>
相关文章
SQL Server--怎样用ADO在SQL SERVER中建库,建表
SQL Server--怎样用ADO在SQL SERVER中建库,建表...2006-08-08set rs=server.CreateObject("adodb.recordset") 的中文详
这是创建一个数据库实例,但是什么是数据库实例?还有rs这个东西也不是一个变量,他在程序里边rs.update 等操作是如何进行的?打开的表示如何接收rs传过来的数据的?2010-08-08asp Driver和Provider两种连接字符串连接Access时的区别
Microsoft OLE DB Provider for ODBC Drivers 错误 '80040e21' 多步 OLE DB 操作产生错误。如果可能,请检查每个 OLE DB 状态值。没有工作被完成。2009-12-12
最新评论