codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:



Home » Visual Basic » Article

Visual Basic Compact/Repair Access Database Utility

Article by: Kenneth Ives (3/29/2003)
Bookmark us now! Add to Favourites
Email a friend!Tell a friend
Summary: This utility will compact and repair the access database you select. It is actually more convenient to use this utility than do the same task with Access, because you don't have to save the database with a different name and then delete the old database when you are done: here, a temporary copy of the database is automatically created and deleted.
Viewed: 113930 times Rating (24 votes): 
 4.1 out of 5
 Rate this Article  Read Comments  Post Comments

Visual Basic Compact/Repair Access Database Utility



Download Now (237KB)

This utility will compact and repair the access database you select. It is actually more convenient to use this utility than do the same task with Access, because you don't have to save the database with a different name and then delete the old database when you are done: here, a temporary copy of the database is automatically created and deleted.

In addition, the utility reports the file space freed up and the compression percentage when it is done. Documentation and comments are very good.

Be sure to also make a reference in the IDE to:

Microsoft ActiveX Data Objects 2.x Library
Microsoft Jet and Replication Objects 2.x Library

Important information:

YOU MUST KNOW THE TYPE OF DATABASE TO BE COMPACTED!

If you compact an earlier database with a higher version type, the database will be corrupted forever.

This application will compact and repair MS Access (*.mdb) databases only.

Features:
  • Now has the capability to use the windows interface or open a DOS window and use the command line. If used in a batch file then Windows must be running.
  • Logs start and finish times to a log file to be determined by the user. If this parameter is left blank, then the folder where the database resides is where the log file will be created. Error messages are also logged.
  • If using command line parameters, no message boxes should appear. All information will be logged to the log file. (_YYYYMM.log) See sample log file. Any batch processing must be run in a DOS window.
  • User defined work folder where the compact/repair process will take place. If this parameter is left blank, then the folder where the database resides is where the processing will take place.

CompMDB Command Line Options

***** IMPORTANT ***** YOU MUST KNOW THE TYPE OF DATABASE OR IT MAY BECOME CORRUPTED FOREVER!

Syntax:
 CompMDB /Ffilename /Ssource_folder /Ttype_of_database 
                    [/Llog_folder] [/Wwork_folder] [/Ddelete_backup]


CompMDB /sC:\Program Files\Microsoft Office /T5 /Fnorthwind.mdb


Note: All required parameters must be entered. You can enter the parameters in any order and you do not have to separate them with spaces. Double quotes do not have to be used to wrap long filenames.

***** IMPORTANT ***** YOU MUST KNOW THE TYPE OF DATABASE OR IT MAY BECOME CORRUPTED FOREVER!

Required prameters:
/F    Name of the database (Without any path information)
/S    Path to where the database resides
/T    Type of database (4 = Access 95/97    5 = Access 2000/2002)


Optional parameters:
/D     Y or N  to delete backup copy of database after the 
            compact/repair has completed. Default = "N"
/L     Path to log folder. If missing, /S parameter will be used.
/W     Path to temp work folder. If missing, /S parameter will be used.
/? or ?   This online help message  


Important: There are no warning messages when the process is running. Verify the type of database and enter the appropriate value.

Any batch processing must be run in a DOS window not a DOS prompt.

Sample batch file:

@echo off
cls
REM ******************************************************************************
REM ** DB name is MyDatabase.mdb Access 2000 Type 5 Delete backup when finished
REM ******************************************************************************
echo. Compacting MyDatabase.mdb
CompMDB.exe /dMyDatabase.mdb /T5 /sD:\Misc Databases /LC:\Log2001 /DY /wC:\WorkArea

REM ******************************************************************************
REM ** DB name is Archive.mdb Access 95 Type 4 Delete backup when finished
REM ******************************************************************************
echo. Compacting Archive.mdb
CompMDB.exe /dArchive.mdb /T4 /sD:\Misc Databases /LC:\Log2001 /DY /wC:\WorkArea

REM ******************************************************************************
REM ** DB name is John.mdb Access97 Type 4 Do not delete backup when finished
REM ******************************************************************************
echo. Compacting John.mdb
CompMDB.exe /dJohn.mdb /T4 /sD:\Misc Databases /LC:\Log2001 /wC:\WorkArea

echo. Finshed!
echo.





CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
Rate this article:     Poor Excellent
View highlighted Comments
User Comments on 'Visual Basic Compact/Repair Access Database Utility'
RELATED ARTICLES
Generate License Keys (such as CD keys on Microsoft software)
by Brian Gillham
This class allows you to generate license keys, such as the CD keys on the case of most Microsoft software
Communicating with the Database (Using ADO)
by Chaudhary Pradeep K. Roy
Using ADO to get connected with the database.
Visual Basic Read and Modify the Registry
by Kenneth Ives
Perform the four basic functions to the Windows registry. Add, change, delete, and query. Allows you to to read registry values, and modify both keys and values.
Generate an Array of Unique Random Numbers
by Brian Gillham
This function will generate an ARRAY of TRULY random numbers.
Beginning Resource Files in Visual Basic
by Kenneth Ives
Have you ever wanted to use graphics, such as icons, bitmaps, cursors, and AVI files? How about sound or even message box text? This can be an enormous amount of overhead. These are all examples of more files to keep track of when you distribute an application, DLL, or OCX. Lets find out how resource files can help....
Visual Basic Compact/Repair Access Database Utility
by Kenneth Ives
This utility will compact and repair the access database you select. It is actually more convenient to use this utility than do the same task with Access, because you don't have to save the database with a different name and then delete the old database when you are done: here, a temporary copy of the database is automatically created and deleted.
Creating a watermark in Excel with VBA
by Kenneth Ives
Adding a watermark to an Excel spreadsheet using VBA.
Change Cursor to Hour Glass
by Brian Gillham
A simple script to change the cursor to an hour glass.
Generate your own Random Numbers
by Thaha Hussain
This simple program generates random numbers using the basic mathematical methods.
Analog Clock
by Thaha Hussain
This program demonstrates Thaha Hussain's Clock Work Formula to paint an Analogue Clock.








Recent Forum Threads
• Game:Colonization based with HTML5 Canvas and JavaScript
• Pointwise.GridGen.v15.18
• Global.Mapper.v15.2.3.b060614
• Geometric_Glovius_Pro_v3.6.1
• VERO.SurfCAM.v2014
• Schlumberger.Petrel.V2013.2
• Petrel.V2013.2
• Altair.HyperWorks.v12
• VoluMill.v6.1


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2014