Access数据库在线压缩的实现方法
2008-12-17 23:35
363 查看
<script type="text/javascript"><!--
google_ad_client = "pub-4490194096475053";
/* 内容页,300x250,第一屏 */
google_ad_slot = "3685991503";
google_ad_width = 300;
google_ad_height = 250;
// --></script>
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>
如果在 Access 数据库中删除数据或对象,或者在 Access 项目中删除对象,Access 数据库或 Access 项目可能会产生碎片并会降低磁盘空间的使用效率。压缩 Access 数据库或Access项目实际上是复制该文件,并重新组织文件在磁盘上的存储方式。压缩同时优化了 Access 数据库和 Access 项目的性能。
所以我们在对日益增大的数据库导致的ASP程序慢得无法忍受的时候,就想到了要压缩他。但常规的做法把他下载到本地然后用MSaccess来完成压缩操作,然后再上传!
需要注意的是:本程序其实是通过FSO权限和JET引擎连接,因此在使用之前请确认你的服务器支持FSO(filesystemobject)权限并安装的ACCESS最新驱动!从安全出发,请在压缩之前备份原始数据库!已经测试通过的运行环境:
WIN98SE+PWS、WIN2000+IIS5.0
下面是我整理后的源代码,复制另存为compact.asp并上传到数据库所在目录即可正常使用。
<html>
<head>
<title>ACCESS数据库压缩程序</title>
</head>
<body bgcolor="e0f8ef">
<div>
<div align="center"><font color="#3300FF">
<b><font size="5">通用ACCESS数据库在线压缩程序</font></b></font><br>
</div>
<div><br>
本程序其实是通过FSO权限和JET引擎连接,
因此在使用之前请确认你的服务器支持FSO
(filesystemobject)权限并安装的ACCESS最新驱动!
从安全出发,请在压缩之前备份原始数据库!
</div><br>
<div align="center">运行环境:在WIN98SE+PWS、WIN2000+IIS5.0 <br>
<%
Const JET_3X = 4
Function CompactDB(dbPath, boolIs97)
Dim fso, Engine, strDBPath
strDBPath = left(dbPath,instrrev(DBPath,""))
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(dbPath) Then
Set Engine = CreateObject("JRO.JetEngine")
If boolIs97 = "True" Then
Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbpath, _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp.mdb;" _
& "Jet OLEDB:Engine Type=" & JET_3X
Else
Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbpath, _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp.mdb"
End If
fso.CopyFile strDBPath & "temp.mdb",dbpath
fso.DeleteFile(strDBPath & "temp.mdb")
Set fso = nothing
Set Engine = nothing
CompactDB = "你的数据库, " & dbpath & ", 已经被压缩" & vbCrLf
Else
CompactDB = "你输入的数据库路径或名称未找到,请重试" & vbCrLf
End If
End Function
%>
</div>
</div>
<form name="compact" method="post" action="compact.asp">
<div align="center">
<font size="2"><b><font color="#FF0000">
压缩选项,请仔细填写!</font></b><br>
<br>
输入数据库全称:
<input type="text" name="dbpath">
(包括扩展名,如MDB、ASA、ASP等)<br>
<br>
<input type="checkbox" name="boolIs97" value="True">
检查是否为ACCESS97数据库<br>
(默认为ACCESS2000的数据库)<br>
<br>
<input type="submit" name="submit" value="确认压缩">
</font></div>
</form>
<div align="center"><font size="2">
<%
Dim dbpath,boolIs97
dbpath = request("dbpath")
boolIs97 = request("boolIs97")
If dbparesponse.write(CompactDB(dbpath,boolIs97))
End If
%>
<br>
</font></div></body></html>th <> "" Then
dbpath = server.mappath(dbpath)
<script type="text/javascript"><!--
google_ad_client = "pub-4490194096475053";
/* 728x90, 创建于 08-12-8 */
google_ad_slot = "0403648181";
google_ad_width = 728;
google_ad_height = 90;
// --></script>
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>
google_ad_client = "pub-4490194096475053";
/* 内容页,300x250,第一屏 */
google_ad_slot = "3685991503";
google_ad_width = 300;
google_ad_height = 250;
// --></script>
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>
如果在 Access 数据库中删除数据或对象,或者在 Access 项目中删除对象,Access 数据库或 Access 项目可能会产生碎片并会降低磁盘空间的使用效率。压缩 Access 数据库或Access项目实际上是复制该文件,并重新组织文件在磁盘上的存储方式。压缩同时优化了 Access 数据库和 Access 项目的性能。
所以我们在对日益增大的数据库导致的ASP程序慢得无法忍受的时候,就想到了要压缩他。但常规的做法把他下载到本地然后用MSaccess来完成压缩操作,然后再上传!
需要注意的是:本程序其实是通过FSO权限和JET引擎连接,因此在使用之前请确认你的服务器支持FSO(filesystemobject)权限并安装的ACCESS最新驱动!从安全出发,请在压缩之前备份原始数据库!已经测试通过的运行环境:
WIN98SE+PWS、WIN2000+IIS5.0
下面是我整理后的源代码,复制另存为compact.asp并上传到数据库所在目录即可正常使用。
<html>
<head>
<title>ACCESS数据库压缩程序</title>
</head>
<body bgcolor="e0f8ef">
<div>
<div align="center"><font color="#3300FF">
<b><font size="5">通用ACCESS数据库在线压缩程序</font></b></font><br>
</div>
<div><br>
本程序其实是通过FSO权限和JET引擎连接,
因此在使用之前请确认你的服务器支持FSO
(filesystemobject)权限并安装的ACCESS最新驱动!
从安全出发,请在压缩之前备份原始数据库!
</div><br>
<div align="center">运行环境:在WIN98SE+PWS、WIN2000+IIS5.0 <br>
<%
Const JET_3X = 4
Function CompactDB(dbPath, boolIs97)
Dim fso, Engine, strDBPath
strDBPath = left(dbPath,instrrev(DBPath,""))
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(dbPath) Then
Set Engine = CreateObject("JRO.JetEngine")
If boolIs97 = "True" Then
Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbpath, _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp.mdb;" _
& "Jet OLEDB:Engine Type=" & JET_3X
Else
Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbpath, _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp.mdb"
End If
fso.CopyFile strDBPath & "temp.mdb",dbpath
fso.DeleteFile(strDBPath & "temp.mdb")
Set fso = nothing
Set Engine = nothing
CompactDB = "你的数据库, " & dbpath & ", 已经被压缩" & vbCrLf
Else
CompactDB = "你输入的数据库路径或名称未找到,请重试" & vbCrLf
End If
End Function
%>
</div>
</div>
<form name="compact" method="post" action="compact.asp">
<div align="center">
<font size="2"><b><font color="#FF0000">
压缩选项,请仔细填写!</font></b><br>
<br>
输入数据库全称:
<input type="text" name="dbpath">
(包括扩展名,如MDB、ASA、ASP等)<br>
<br>
<input type="checkbox" name="boolIs97" value="True">
检查是否为ACCESS97数据库<br>
(默认为ACCESS2000的数据库)<br>
<br>
<input type="submit" name="submit" value="确认压缩">
</font></div>
</form>
<div align="center"><font size="2">
<%
Dim dbpath,boolIs97
dbpath = request("dbpath")
boolIs97 = request("boolIs97")
If dbparesponse.write(CompactDB(dbpath,boolIs97))
End If
%>
<br>
</font></div></body></html>th <> "" Then
dbpath = server.mappath(dbpath)
<script type="text/javascript"><!--
google_ad_client = "pub-4490194096475053";
/* 728x90, 创建于 08-12-8 */
google_ad_slot = "0403648181";
google_ad_width = 728;
google_ad_height = 90;
// --></script>
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>
相关文章推荐
- Access数据库在线压缩的实现方法
- .net在线备份压缩修复Access数据库方法
- C#使用晚绑定来实现压缩Access数据库的方法
- 用ASP.NET实现文件的在线压缩和解压缩
- PHP实现压缩图片尺寸并转为jpg格式的方法示例
- 压缩access数据库的方法。
- 在线实现WINRAR压缩和解压缩
- iOS实现图片压缩的两种方法及图片压缩上传功能
- openjweb中使用fckedit和struts2实现在线编辑人员简历的方法
- Python实现压缩与解压gzip大文件的方法
- Asp.net在线备份、压缩和修复Access数据库
- 用ASP实现在线压缩与解压缩
- python实现在pickling的时候压缩的方法
- asp.net实现word文档在线查看功能 (三种方法)
- 实现在线压缩文件的实现程序代码
- 实现在线阅读的方法,如百度文库一样。
- Android编程实现将压缩数据库文件拷贝到安装目录的方法
- 用ASP.Net实现文件在线压缩和解压缩
- python gzip模块实现文件压缩的方法
- asp.net在线压缩和解压缩的实现