欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

压缩并备份Access数据库

程序员文章站 2022-05-17 08:39:38
...

Function CompactDB(Access_Url,Access_Backup_Url,BKDBName,Is97) Dim FSO Set FSO=CreateObject(Scripting.FileSystemObject) If FSO.FileExists(Access_Url) Then Dim JE Set JE=CreateObject(JRO.JetEngine) If Is97=True Then JE.CompactDatabase Provi

Function CompactDB(Access_Url,Access_Backup_Url,BKDBName,Is97)
Dim FSO
Set FSO=CreateObject("Scripting.FileSystemObject")

If FSO.FileExists(Access_Url) Then
Dim JE
Set JE=CreateObject("JRO.JetEngine")

If Is97=True Then
JE.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Access_Url,"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Access_Backup_Url&"temp.mdb;Jet OLEDB:Engine Type=4"
Else
JE.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Access_Url,"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Access_Backup_Url&"temp.mdb"
End If

FSO.CopyFile Access_Backup_Url&"temp.mdb",Access_Url
FSO.CopyFile Access_Backup_Url&"temp.mdb",Access_Backup_Url&BKDBName&".asa"
FSO.DeleteFile(Access_Backup_Url&"temp.mdb")

Set FSO=nothing
Set JE=nothing

CompactDB="你的数据库,已经被压缩备份!"
Else
CompactDB="你输入的数据库路径或名称未找到,请重试!"
End If
End Function

Dim Access_Url,Access_Backup_Url,BKDBName

Access_Url="E:\SCJD\Admin\SCJD_Data\%50%69%7a%69%67%65.mdb" '数据库的物理路径
Access_Backup_Url="E:\SCJD\Admin\SCJD_Backup\" '数据库备份的物理路径
BKDBName="%50%69%7a%69%67%65" '数据库备份的文件名

Response.Write CompactDB(Access_Url,Access_Backup_Url,BKDBName,False)

孤狼