Online compression of Access databases

Source: Internet
Author: User
If you delete data or objects in an Access database or delete objects in an Access project, access database or Access project may cause fragmentation and reduce disk space usage efficiency. The compressed Access database or Access project copies the file and re-organizes the file on the disk.

If you delete data or objects in an Access database or delete objects in an Access project, access database or Access project may cause fragmentation and reduce disk space usage efficiency. The compressed Access database or Access project copies the file and re-organizes the file on the disk.

Online compression of Access databases

If you delete data or objects in the Access database or delete objects in the Access Project, the Access database or Access project may produce fragments and reduce the disk space usage efficiency. Compressing the Access database or Access project is actually copying the file and reorganizing the storage mode of the file on the disk. Compression also optimizes the performance of the Access database and Access project.

So when we were unable to bear the slow ASP program caused by the increasing database, we thought of compressing it. But the conventional practice is to download it to the local computer and then use MSaccess to complete the compression operation, and then upload it again!

Note that this program is actually connected to the JET engine through the FSO permission. Therefore, before using it, please confirm that your server supports the FSO (filesystemobject) Permission and install the latest ACCESS driver! For security reasons, back up the original database before compression! Environment that has passed the test:

WIN98SE + PWS, WIN2000 + IIS5.0

The following is my source code. Copy and save it as compact. asp and upload it to the database directory.



ACCESS Database compression program




Online compression program for general ACCESS databases




This program is actually connected to the JET engine through the FSO permission,

Therefore, make sure that your server supports FSO before use.

(Filesystemobject) Permission and install the latest ACCESS driver!

For security reasons, back up the original database before compression!



Running Environment: In WIN98SE + PWS, WIN2000 + IIS5.0

<%
Const JET_3X = 4
Function CompactDB (dbPath, boolIs97)
Dim fso, Engine, strDBPath
StrDBPath = left (dbPath, limit 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 =" & 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 = "your database," & dbpath & ", already compressed" & vbCrLf
Else
CompactDB = "the path or name of the database you entered is not found. Please try again" & vbCrLf
End If
End Function
%>





<%
Dim dbpath, boolIs97
Dbpath = request ("dbpath ")
BoolIs97 = request ("boolIs97 ")
If dbparesponse. write (CompactDB (dbpath, boolIs97 ))
End If
%>


Th <> "" Then
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.