Print Page | Close Window

How do you compact access db?

Printed From: Web Wiz Forums
Category: Web Wiz Web App Support Forums
Forum Name: Web Wiz Forums
Forum Description: Support forum for Web Wiz Forums application.
URL: https://forums.webwiz.net/forum_posts.asp?TID=5388
Printed Date: 02 April 2026 at 10:49pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: How do you compact access db?
Posted By: serendipity
Subject: How do you compact access db?
Date Posted: 30 August 2003 at 9:54pm

I have seen a lot of mention of regularly compacting access database, however I could not find any info in the documentation or on this forum on how to do that.  Can someone let me know?  Sounds like this is something I should be doing on a regular basis.

serendipity




Replies:
Posted By: 808Rider
Date Posted: 31 August 2003 at 12:09am

Open your database on your PC and in the menu bar go to Tools > Database Utilities > Compact and Repair Database



-------------
PodcastPUP: http://podcastpup.com - http://podcastpup.com
808Talk: http://808Talk.com - http://808Talk.com
808TTV: http://808Talk.tv - http://808Talk.tv


Posted By: serendipity
Date Posted: 02 September 2003 at 3:27pm
Thank you!


Posted By: serendipity
Date Posted: 02 September 2003 at 6:08pm
Errr, don't suppose anyone knows how to do on a Mac?? OS X operating system??


Posted By: eksimba
Date Posted: 02 September 2003 at 11:46pm

With the right file permissions, you should be able to do it with an .asp page. An example that I just succesfully tested can be found at:

http://www.asperium.com/Articles/ShowArt.asp?Cat=ASP&Article=30 - http://www.asperium.com/Articles/ShowArt.asp?Cat=ASP&Article=30

Originally posted by asperium asperium wrote:

<%

Const Jet_Conn_Partial = "Provider=Microsoft.Jet.OLEDB.4.0; Data source="
Dim strDatabase, strFolder, strFileName

'#################################################
'# Edit the following two lines
'# Define the full path to where your database is
strFolder = "F:\InetPub\wwwroot\_db\"
'# Enter the name of the database
strDatabase = "YourAccessDatabase.mdb"
'# Stop editing here
'##################################################

Private Sub dbCompact(strDBFileName)
Dim SourceConn
Dim DestConn
Dim oJetEngine
Dim oFSO

SourceConn = Jet_Conn_Partial & strFolder & strDatabase
DestConn = Jet_Conn_Partial & strFolder & "Temp" & strDatabase

Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
Set oJetEngine = Server.CreateObject("JRO.JetEngine")

With oFSO

       If Not .FileExists(strFolder & strDatabase) Then
           Response.Write ("Not Found: " & strFolder & strDatabase)
           Stop
       Else
                 If .FileExists(strFolder & "Temp" & strDatabase) Then
                       Response.Write ("Something went wrong last time " _
                       & "Deleting old database... Please try again")
                      .DeleteFile (strFolder & "Temp" & strDatabase)
                 End If
      End If
End With

With oJetEngine
.CompactDatabase SourceConn, DestConn
End With

oFSO.DeleteFile strFolder & strDatabase
oFSO.MoveFile strFolder & "Temp" _
& strDatabase, strFolder& strDatabase

Set oFSO = Nothing
Set oJetEngine = Nothing
End Sub

Private Sub dbList()
Dim oFolders
Set oFolders = Server.CreateObject("Scripting.FileSystemObject")
   Response.Write ("<Select Name=""DBFileName"">")
   For Each Item In oFolders.GetFolder(strFolder).Files
   If LCase(Right(Item, 4)) = ".mdb" Then
       Response.Write ("<Option Value=""" & Replace(Item, strFolder, "") _
       & """>" & Replace(Item, strFolder, "") & "</Option>")
   End If
Next
Response.Write ("</Select>")

Set oFolders = Nothing
End Sub


%>
<%
' Compact database and tell the user the database is optimized
Select Case Request.form("cmd")
Case "Compact"
dbCompact Request.form("DBFileName")
Response.Write ("Database " & Request.form("DBFileName") & " is optimized.")
End Select
%>

<p><font size="4">Compact and repair database</font></p>
<form method="POST" action="">
<p><%dbList%><input type="submit" value="Compact" name="cmd"></p>
</form>



-------------
- eric


Posted By: WebWiz-Bruce
Date Posted: 03 September 2003 at 2:08am
In the next version of the forum you will be able to compact and repair the database online from the forums admin area.

-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: serendipity
Date Posted: 03 September 2003 at 9:48am
Thank you eksimba! I'll give it a whirl.

-boRg-, that will be a very nice addition to next version of forum.


Posted By: eksimba
Date Posted: 03 September 2003 at 12:04pm

That'll be a great addition, -boRg- !



-------------
- eric



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net