首页  新闻动态  文化知识  网络文摘  生活时尚  娱乐休闲  健康频道  外语学习  软件教学  程序设计  独山图片  书店网站 
  程序设计 > Asp/Vbscript > 正文
 

Access数据库压缩代码

来源:独山在线 [2008-10-26]   浏览次数:4993
<%
If AccessCompact("db.mdb") = True Then
Response.Write("Access 数据库压缩成功!!!")
Else
Response.Write("Access 数据库压缩失败......")
End If

Function AccessCompact(AccessDataPath)
AccessCompact = True
Dim fso, Engine, strAccFullPath,AccFullPath,strTempFile
On Error Resume Next
Err = 0
AccFullPath=Server.MapPath(AccessDataPath)
strAccFullPath = Left(AccFullPath,InStrRev(AccFullPath,"\"))
strTempFile = "AccTempData.mdb"
SET fso = Server.CreateObject("Scripting.FileSystemObject")
If Err <> 0 Then
AccessCompact = False
Err = 0
Exit Function
End If
If fso.FileExists(AccFullPath) = False Then
AccessCompact = False
Exit Function
End If

SET Engine = CreateObject("JRO.JetEngine")
If Err <> 0 Then
AccessCompact = False
Err = 0
Exit Function
End If
Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & AccFullPath," Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strAccFullPath & strTempFile
fso.CopyFile strAccFullPath & strTempFile,AccFullPath
fso.DeleteFile(strAccFullPath & strTempFile)
SET fso = Nothing
SET Engine = Nothing
If Err <> 0 Then
AccessCompact = False
End If
Err = 0
End Function
%>
>>上篇:Access数据库防下载设置代码
>>下篇:首页转成静态程序
 
 
版权所有:独山在线 copyright ©2007-2024 www.dushan.net, All Rights Reserved.
   免责声明:本网转载或链接出于传递更多信息之目的,并不意味着赞同其观点或证实其内容的真实性。
   本站为公益性网站,旨在宣传独山,如有侵犯请和我们联系,经查实将及时删除! 工信部备案:黔ICP备07001263号-3