Compress an Access database online

Source: Internet
Author: User
Tags compact access database
access| Data | database | compression | Online while working on Builddb/buildapp on-line Demo, I developed a little function that would compact Access Databases over the web. Here's a "no-frills" page that's ll compact the databases for you.
One problem with Access databases was that "holes" are created when records are, deleted the database making and fluffy Ated. Compacting the database makes it lean and efficient again.

Note:this Function/page can easily is combined with the Buildapp front end file navigation and search pages (installment II), to create a application that ' ll make it easy to handle this formerly troublesome chore for all the databases on your Machine/web site.



++++++++++++ Begin compact.asp +++++++++++++++++++++++++++++
<%
Option Explicit
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 = "Your database," & DBPath & ", has been compacted" & VbCrLf
Else
COMPACTDB = "The database name or path has not been found. Try Again "& vbCrLf
End If

End Function
%>

&LT;H2 align= "center" > Compacting an Access database<p align= "center" >
<form action=compact.asp>
Enter relative path to the database, including database name.<br><br>
<input type= "text" name= "DBPath" ><br><br>
<input type= "checkbox" Name= "boolIs97" value= "True" > Check if Access to the database
<br><i> (default is Access) </i><br><br>
<input type= "Submit" >
<form>
<br><br>
<%
Dim dbpath,boolis97
DBPath = Request ("DBPath")
BOOLIS97 = Request ("BOOLIS97")

If dbpath <> "" Then
DBPath = Server.MapPath (DBPath)
Response.Write (Compactdb (DBPATH,BOOLIS97))
End If
%>
</p></body>
++++++++++++ End Code



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.