Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Compact and Repair Access Database.

Compact and Repair Access Database.

Scheduled Pinned Locked Moved Visual Basic
database
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NANCO
    wrote on last edited by
    #1

    Is there an easy way to Compact and Repair Access Database.:cool:

    K 1 Reply Last reply
    0
    • N NANCO

      Is there an easy way to Compact and Repair Access Database.:cool:

      K Offline
      K Offline
      Kschuler
      wrote on last edited by
      #2

      I found this article which may interest you: http://support.microsoft.com/default.aspx?scid=kb;en-us;Q303528[^] I wrote a utility to compact an access database using some code that I had found somewhere. I referenced Microsoft DAO 3.6 Object Library Com object and then used the following code:

      Private Sub CompactFile(ByVal strFileIn As String, ByVal strFileOut As String)
      Try
      'First check the file u want to compact exists or not
      If My.Computer.FileSystem.FileExists(strFileIn) Then
      Dim objDAO As New DAO.DBEngine()
      'CompactDatabase has two parameters, creates a copy of compact DB at the Destination path
      objDAO.CompactDatabase(strFileIn, strFileOut)
      End If

          Catch ex As Exception
              MsgBox("Compact File Error: " & ex.Message)
          End Try
      End Sub
      

      Note: This method will save the compacted database under a new name. If you want it to appear that the file itself was compacted you will have to add code to delete the exising db and replace it with the compacted one after you perform this method. Hope this helps.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups