Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - How do you compact access db?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

How do you compact access db?

 Post Reply Post Reply
Author
serendipity View Drop Down
Groupie
Groupie
Avatar

Joined: 10 June 2003
Status: Offline
Points: 43
Post Options Post Options   Thanks (0) Thanks(0)   Quote serendipity Quote  Post ReplyReply Direct Link To This Post Topic: How do you compact access db?
    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

Back to Top
808Rider View Drop Down
Senior Member
Senior Member

Vebro Solutions CEO http://www.vebro.net

Joined: 20 April 2003
Status: Offline
Points: 405
Post Options Post Options   Thanks (0) Thanks(0)   Quote 808Rider Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
serendipity View Drop Down
Groupie
Groupie
Avatar

Joined: 10 June 2003
Status: Offline
Points: 43
Post Options Post Options   Thanks (0) Thanks(0)   Quote serendipity Quote  Post ReplyReply Direct Link To This Post Posted: 02 September 2003 at 3:27pm
Thank you!
Back to Top
serendipity View Drop Down
Groupie
Groupie
Avatar

Joined: 10 June 2003
Status: Offline
Points: 43
Post Options Post Options   Thanks (0) Thanks(0)   Quote serendipity Quote  Post ReplyReply Direct Link To This Post Posted: 02 September 2003 at 6:08pm
Errr, don't suppose anyone knows how to do on a Mac?? OS X operating system??
Back to Top
eksimba View Drop Down
Groupie
Groupie


Joined: 23 April 2003
Location: United States
Status: Offline
Points: 48
Post Options Post Options   Thanks (0) Thanks(0)   Quote eksimba Quote  Post ReplyReply Direct Link To This Post 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

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
Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
serendipity View Drop Down
Groupie
Groupie
Avatar

Joined: 10 June 2003
Status: Offline
Points: 43
Post Options Post Options   Thanks (0) Thanks(0)   Quote serendipity Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
eksimba View Drop Down
Groupie
Groupie


Joined: 23 April 2003
Location: United States
Status: Offline
Points: 48
Post Options Post Options   Thanks (0) Thanks(0)   Quote eksimba Quote  Post ReplyReply Direct Link To This Post Posted: 03 September 2003 at 12:04pm

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

- eric
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.