当前位置: 首页 > 图文教程 > 数据库 > Access > ASP压缩ACCESS数据库实例

Access
如何给ODBC连接打开连接池
Access数据库与SQLserver2000的数据互导
如何在退出整个系统前提示用户
通过查询返回数据库对象的名称
Delphi中的Access技巧集
ACCESS中如何插入超级链接?
怎样用代码隐藏、最大化、最小化ACCESS的主窗口
操作系统环境 Environ 函数
ACCESS2000升迁向导“溢出”错误处理方法
如何在ACCESS中压缩当前数据库
在VB中用代码打印ACCESS报表
以指定工作组文件启动MDB文件
长期使用中型Access数据库的一点经验
显示数据库窗口的捷径
取得磁碟机之Volumn及Serial Number
ACCESS默认保存路径的修改方法
数据库设计范式
Access无需DSN文件快速连接SQL Server方法
用Access 2000进行班级管理
启动命令行选项

Access 中的 ASP压缩ACCESS数据库实例


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-17   浏览: 56 ::
收藏到网摘: n/a

用ACCESS数据库开发的网站,当随着网站数据量的不断增长.数据库的容量也是不断加大.这让ASP程序速度直线下降.如果才能让ACCESS数据库容量尽可能小.我们要对它进行压缩处理.

下面是我整理后的源代码,复制另存为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)

注意:由于本例实用的是FSO操作ACCESS文件,所以要使用本例请确保你的服务器支持FSO支持.

佚名