Methods for online compression of Access databases

Source: Internet
Author: User
Tags compact access database

methods for online compression of Access databases

If you delete data or objects in an Access database, or if you delete an object in an Access project, an Access database or an Access project can cause fragmentation and reduce the efficiency of disk space usage. Compressing an Access database or an Access project actually copies the file and organizes how the file is stored on disk. Compression also optimizes the performance of Access databases and Access projects.

So we think of compressing it when we're too slow to tolerate an ASP program that's growing in the database. But the usual way to download him to the local and then use MSAccess to complete the compression operation, and then upload!

Note: This program is actually through the FSO permissions and the Jet engine connection, so before using, please confirm your server support FSO (FileSystemObject) permissions and install the latest driver of access! From a safe start, please back up the original database before compacting! The running environment that has been tested through:

WIN98SE+PWS, win2000+iis5.0

The following is my collation of the source code, copy saved as Compact.asp and uploaded to the database directory can be used normally.

<title>access Database Compression Program </title>
<body bgcolor= "E0f8ef" >
<div>
<div align= "center" ><font color= "#3300FF" >
<b><font size= "5" > Universal Access Database online compression program </font></b></font><br>
</div>
<div><br>
This program is actually through the FSO permissions and the Jet engine connection,

So make sure your server supports the FSO before using it

(filesystemobject) Permissions and install the latest drivers for access!

From a safe start, please back up the original database before compacting!

</div><br>
<div align= "center" > Run Environment: WIN98SE+PWS, win2000+iis5.0 <br>
<%
Const jet_3x = 4
Function compactdb (DBPath, boolIs97)
Dim fso, Engine, strdbpath
Strdbpath = Left (dbpath,instr Rev (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= "& Amp DBPath, _
"Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Strdbpath & "Temp.mdb;" _
& "Jet oledb:en Gine 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 = "Your database," & DBPath &, has been compressed "& vbCrLf
Else
Compactdb =" The database path or name you entered is not found, please retry "& VbCrLf
E nd If
End Function
%>
</div>
</div>
<form name= "compact" method= "POST" action= " Compact.asp ""
<div align= "center"
<font size= "2" ><b><font color= "#FF0000"
Compression options, please carefully fill out! </font></b><br>
<br>

Enter the full name of the database:

<input type= "text" name= "DBPath" >
(including extensions, such as MDB, ASA, ASP, etc.) <br>
<br>
<input type= "checkbox" Name= "boolIs97" value= "True" >
Check for ACCESS97 database <br>
(The default is ACCESS2000 database) <br>
<br>
<input type= "Submit" name= "Submit" value= "confirm Compression" >
</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>DBPath = Server.MapPath (DBPath)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.