Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 880059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:02:02+00:00 2026-05-15T12:02:02+00:00

I have a site that uses classic ASP and a database in Access 2007

  • 0

I have a site that uses classic ASP and a database in Access 2007 format (.accdb). It is encrypted with a password and is about 300 MiB in file size.

The site works fine by itself but every now and then the database gets corrupted (the error is “unrecognized database format”). It can be fixed easily by opening the database in MS Access, then it will be repaired. Problem is it can take days before I notice the database is corrupted and during that time the site will be useless. Sometimes it takes months between each corruption, other times only a week or two.

What I want is the site to be able to call the “Compact and Repair Database” function itself every now and then (once a day or so) to keep the database in a working condition.

My question is how do I do this, make it repair itself?

I found this article: How do I compact and repair an ACCESS 2007 database by .NET code?
…but I don’t understand how I can make that work for me. I only know classic ASP and Java.

Can anyone write a little isolated ASP code that does this: “open connection to password-protected database”, “repairs the database”, “close the connection”.

The site and database is on a dedicated server which I have full control over so I can implement any solution that exists.

Thank you very much!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T12:02:03+00:00Added an answer on May 15, 2026 at 12:02 pm

    I got the answer I needed in another question I asked:
    Why can't I use "CompactDatabase" in DAO.DBEngine.36 using VBscript?

    The user “HansUp” gave me the following code:

    Dim objFSO 
    Dim objEngine 
    Dim strLckFile 
    Dim strSrcName 
    Dim strDstName 
    Dim strPassword

    strLckFile = "C:\Access\webforums\foo.laccdb"
    strSrcName = "C:\Access\webforums\foo.accdb"
    strDstName = "C:\Access\webforums\compacted.accdb"
    strBackup = "C:\Access\webforums\foobackup.accdb"
    strPassword = "foo"

    Set objEngine = CreateObject("DAO.DBEngine.120")

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    If Not (objFSO.FileExists(strLckFile)) Then
    If (objFSO.FileExists(strBackup)) Then
    objFSO.DeleteFile strBackup
    End If
    If (objFSO.FileExists(strDstName)) Then
    objFSO.DeleteFile strDstName
    End If
    objFSO.CopyFile strSrcName, strBackup

    ''dbVersion120 = 128  
    objEngine.CompactDatabase strSrcName, strDstName, , 128, ";pwd=" & strPassword
    
    objFSO.DeleteFile strSrcName 
    objFSO.MoveFile strDstName, strSrcName 
    

    End If 'LckFile

    (The code got a few extra line breaks when I copied it for some reason, follow the link at the beginning of this post for a little cleaner version of the code if you wish.)

    It compresses a Access 2007 database to a Access 2007 database (no format change) AND it also repairs any corruption (inconsistent state) in the database! Just what I was looking for. =)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have an ASP.NET application running at a customer site that uses ActiveDirectory for
I have a web site in asp.net that uses a master page. In this
I have a site that uses a couple DropDownLists that are databound. I was
I have a web site that I administer that uses Apache 2.0 on the
I have a site I made really fast that uses floats to display different
I have a simple PowerShell script that uses WMI to create a web site
I have a site that processes orders taken by phone into a SQL database.
I have a site that requires Windows Authentication the application obtains the credential from
I have a site that is using x509 client certificates (2 way SSL) to
I have a site that usually has news items at the top of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.