Search
  • For Individuals
      « Back
    • Windows Data Recovery

      Recovers lost or deleted Office documents, emails, presentations & multimedia files.

      Free Standard Professional Premium

    • Mac Data Recovery

      Recovers deleted files, photos, videos etc. on Mac.

      Free Standard Professional Premium

    • Photo Recovery

      Recover photos, videos, & audio files from all cameras and storage on Windows or Mac.

      Free Standard Professional Premium

    • Video Repair
    • Photo Repair
    • iPhone Data Recovery
  • For Business
      « Back
    • Email Repair & Converter

      Repair for Exchange Converter for EDB Converter for OST Converter for NSF Converter for OST MBOX Repair for Outlook

    • Database & File Repair

      Repair for MS SQL Repair for Access Repair for QuickBooks Software Repair for Excel Extractor for Windows Backup Repair for MySQL

    • Data Recovery & Erasure

      Data Recovery Professional Data Recovery Technician Mac Recovery for Technician Virtual Machine Recovery File Erasure Software Mobile Erasure Drive Erasure File Eraser Software File Eraser Software for Mac

    • Toolkit

      Exchange Toolkit Outlook Toolkit File Repair Toolkit MS SQL Toolkit Data Recovery Toolkit

    • Forensic

      Email Forensic Exchange Auditor Log Analyzer for MySQL Log Analyzer for MS SQL

  • Store
  • Partners
  • Services
  • Offers
  • Support

 

  • For Individuals
    DIY software for anyone who works with data.

    Windows Data Recovery Recovers lost or deleted Office documents, emails, presentations & multimedia files

    Free Standard Professional Premium

    Mac Data Recovery Especially for Mac users to recover deleted documents and multimedia files from macOS

    Free Standard Professional Premium

    Video Repair Windows Mac Repair multiple corrupt videos in one go. Supports MP4, MOV & other formats.

    StandardPremium

    Photo Recovery Windows Mac Recover photos, videos, & audio files from all cameras and storage on Windows or Mac.

    Standard Professional Premium

    iPhone Data Recovery Windows Mac Recover deleted photos, videos, contacts, messages etc. directly from iPhone & iPad

    Recover Erase Toolkit

    Photo Repair Windows Mac Repair multiple corrupt photos in one go. Supports JPEG & other formats.

    Standard Professional Premium


  • For Business
    • Email Repair
    • Email Converter
    • File Repair
    • Data Recovery & Erasure
    • Toolkit
    • Forensic

    Exchange Repair Repair corrupt EDB file & export mailboxes to Live Exchange or Office 365

    Outlook PST Repair Repair corrupt PST & recover all mailbox items including deleted emails & contacts

    OLM Repair Repair Outlook for Mac (OLM) 2011 & 2016 backup files & recover all mailbox items

    Exchange Toolkit Repair EDB & Exchange backup file to restore mailboxes, convert OST to PST, & convert EDB to PST

    Active Directory Repair Repair corrupt Active Directory database (Ntds.dit file) & extract all objects in original form

    EDB to PST Convert online & offline EDB file & extract all mailbox items including Public Folders in PST

    OST to PST Convert inaccessible OST file & extract all mailbox items including deleted emails in PST

    NSF to PST Convert IBM Notes NSF file & export all mailbox items including emails & attachments to PST

    MBOX to PST Convert MBOX file of Thunderbird, Entourage & other clients, & export mailbox data to PST

    OLM to PST Convert Outlook for Mac Data File (OLM) & export all mailbox data to PST in original form

    GroupWise to PST Convert GroupWise mail & export all mailbox items - emails, attachments, etc. - to PST

    EML to PST Convert Windows Live Mail (EML) file & export mailbox data - emails, attachments, etc. - to PST

    Office 365 to PST Connect to Office 365 account & export mailbox data to PST and various other formats

    DBX to PST Convert Outlook Express (DBX) file & export all mailbox data - emails, attachments, etc. - to PST

    SQL Repair Repair corrupt .mdf & .ndf files and recover all database components in original form

    Access Repair Repair corrupt .ACCDB and .MDB files & recover all records & objects in a new database

    QuickBooks Repair Repair corrupt QuickBooks® data file & recover all file components in original form

    MySQL Repair Repair MyISAM & InnoDB tables and recover all objects - keys, views, tables, triggers, etc.

    Excel Repair Repair corrupt Excel (.XLS & .XLSX) files and recover tables, charts, chart sheet, etc.

    BKF Repair Repair corrupt backup (BKF, ZIP, VHDX and .FD) files and restore complete data

    Database Converter Interconvert MS SQL, MySQL, SQLite, and SQL Anywhere database files

    PowerPoint Repair Repair corrupt PPT files and restore tables, header, footer, & charts, etc. like new

    File Repair Toolkit Repair corrupt Excel, PowerPoint, Word & PDF files & restore data to original form

    Data Recovery Windows Mac Recover lost or deleted data from HDD, SSD, external USB drive, RAID & more.

    Technician Toolkit

    Tape Data Recovery Retrives data from all types and capacities of tape drives including LTO 1, LTO 2, LTO 3, & others.

    Virtual Machine Recovery Recover documents, multimedia files, and database files from any virtual machine

    File Erasure Permanently wipe files and folders, and erase traces of apps and Internet activity.

    Standard Corporate

    Mobile Erasure Certified and permanent data erasure software for iPhones, iPads, & Android devices

    Drive Erasure Certified and permanent data erasure software for HDD, SSD, & other storage media Windows Mac

    Exchange Toolkit 5-in-1 software toolkit to recover Exchange database, convert EDB to PST, convert OST to PST, restore Exchange backup, and reset Windows Server password.

    Outlook Toolkit Comprehensive software suite to repair PST files, merge PST files, eliminate duplicate emails, compact PST files, and recover lost or forgotten Outlook passwords.

    File Repair Toolkit Powerful file repair utility to fix corrupt Word, PowerPoint, and Excel documents created in Microsoft Office. It also repairs corrupt PDF files and recovers all objects.

    MS SQL Toolkit 5-in-1 software toolkit to repair corrupt SQL database, restore database from corrupt backup, reset database password, analyze SQL logs, & interconvert databases.

    Data Recovery Toolkit Software helps to recovers deleted data from Windows, Mac and Linux storage devices. Also supports recovery from RAIDs & Virtual Drives.

    Email Forensic Advanced email forensic solution for cyber experts to audit, analyze, or investigate emails & gather evidences.

    Exchange Auditor Exchange Server monitoring solution to automate audits, scans and generate reports ìn real-time.

    Log Analyzer for MySQL Analyze forensic details of MySQL server database log files such as Redo, General Query, and Binary Log.

    Log Analyzer for MS SQL Track & analyze MS SQL Server database transactions log files.

    STELLAR EMAIL FORENSIC

    Advanced email forensic tool to analyze and collect the mailbox data of email clients

    Learn More arrow


    All Products

    All Products

    All Products

    All Products

  • Our Partners
  • Lab Services
  • Trending Searches

    Data Recovery

    Photo Recovery

    Video Repair

    iPhone Data Recovery

    File Erasure Software

    Exchange Repair

    OST to PST

    PST Repair

    Raid Recovery

    MS SQL Repair

  • English Deutsch Français Nederlands Italiano Español 日本語 简体中文
  • Support
File Repair 3 minute read

Compact and Repair Access Database using VB.NET

Published on March 16th, 2022
Charanjeet Kaur
Written By
Charanjeet Kaur
Alexis Llontop
Approved By
Alexis Llontop

Summary: The MS Access database file size continues to grow with increasing usage. Large Access database files are prone to corruption and other issues. So, you can reduce the file size by compacting and repairing the Access database file. Read this post to learn how to compact and repair an Access database using VB.NET code. If your database got corrupt due to large size, you can use the advanced MS Access repair tool mentioned in this post.

Compact and Repair Access Database using VB.NET

An Access database file increases in size with the continuous addition of data. Also, the database file can grow in size in any of these situations:

  • MS Access creates temporary objects (that are hidden) for performing several tasks. For instance, Access may create objects to query external sources when used as a back-end. Even though they are no longer needed, these objects remain in the database.
  • When a database object is deleted, the disk space consumed by that object remains empty and is not reclaimed. And, more space on the disk is occupied for a new object.

The large size of the file increases risk of database corruption. The corruption risk is higher when users frequently edit the MEMO fields in a Visual Basic for Applications (VBA) module. To prevent corruption and other issues, you can reduce the Access database file size by compacting and repairing the database.

Contents

  • Why Compact and Repair?
  • How to Compact and Repair Access Database Using VB.NET?
  • What If the Access Database gets Corrupted?
  • Conclusion

Why Compact and Repair?

Running the Compact and Repair utility helps:

  • Reorganize indexes for increasing database efficiency.
  • Reclaim empty space from deleted records or objects.
  • Lower the risk of corruption of a split database.

How to Compact and Repair Access Database Using VB.NET?

You can schedule to compact and repair an Access database through code in VB.NET. However, you must have exclusive access to the database before compacting and repairing it. The detailed steps are as follows:

  • Add a reference to “Microsoft Jet and Replication Objects 2.6 Library”.
  • Copy and paste the following code to display a warning message if the database is in use.
Dim strAccessDBPath As String =”ENTER PATH OF YOUR ACCESS DB”
Dim LockedDbFileInfo As New System.IO.FileInfo(strAccessDBPath.Replace(“.accdb”, “.laccdb”))
        If LockedDbFileInfo.Exists Then
             ‘Give warning that the database is in use.
        End If
  • Create a temporary folder, like TempFolder, and then copy the database using the below query:
Rename(strAccessDBPath, TempFolder.FullName & “\” & “db1.accdb”)
  • Create a JRO JetEngine object and compact the database (i.e., db1 in our case) by calling the compact method. Next, replace the original database with the compacted one. Once the compacting operation is complete, delete the temp folder.
Dim JRO As New JRO.JetEngine
JRO.CompactDatabase(“Provider=Microsoft.Jet.OLEDB.4.0;” & “Data Source= ” & TempFolder.FullName & “\” & “db1.accdb”, _
            “Provider=Microsoft.Jet.OLEDB.4.0;” & “Data Source=” & strAccessDBPath & “;Jet OLEDB:Engine Type=5”)
TempFolder.Delete(True)

What If the Access Database gets Corrupted?

You can run the Compact and Repair tool to fix a corrupted Access database. If the utility fails to repair the database, you can use an advanced Access database repair tool, such as Stellar Repair for Access. The software can help you fix corruption in damaged or corrupted .accdb and .mdb database files. Also, it helps repair tables, modules, macros, and other objects of the database. It even allows repairing a corrupted split Access database and linked tables. The software also previews all the recoverable objects extracted from the corrupt file, including tables, linked tables, queries, etc.  

Conclusion

The size of an Access database can increase rapidly due to the accumulation of temporary database objects that are no longer required. Also, the database size can grow when the disk space occupied by an object is not reclaimed. Furthermore, the large database file size makes it vulnerable to corruption. And so, compacting and repairing the database is crucial to reduce the size of the database file. This blog explained the steps to compact and repair an Access DB through code in VB.NET. The code helps schedule running the Compact and Repair utility.

If the Access database has turned corrupt due to its large size, use Stellar Repair for Access to repair the corrupted DB and restore all its components.

About The Author

Charanjeet

Charanjeet is a Technical Content Writer at Stellar®who specializes in writing about databases, e-mail recovery, and e-mail migration solutions. She loves researching and developing content that helps database administrators, organizations and novices to fix multiple problems related to MS SQL and MySQL databases and Microsoft Exchange.

Best Selling Products

Stellar Repair for Excel

Stellar Repair for Excel software provid

Read More

Stellar Toolkit for File Repair

Microsoft office file repair toolkit to

Read More

Stellar Repair for QuickBooks ® Software

The most advanced tool to repair severel

Read More

Stellar Repair for Access

Powerful tool, widely trusted by users &

Read More

Table of Contents    

  1. Why Compact and Repair?
  2. How to Compact and Repair Access Database Using VB.NET?
  3. What If the Access Database gets Corrupted?
  4. Conclusion

Categories

Related Posts

File Repair

How to Fix “Excel File Name is not Valid” Error?

Stellar Author Charanjeet Kaur April 13, 2022 Read More
Imports being auto converted from raw to jpg
File Repair

Imports being auto converted from RAW to JPG: Solved

Stellar Author Nishat Paiker March 28, 2022 Read More
File Repair

Excel File Couldn’t Open in Protected View

Stellar Author Charanjeet Kaur March 15, 2022 Read More

Stellar Official Website

Stellar Data Recovery Inc.
48 Bridge Street Metuchen,
New Jersey 08840,
United States

ALSO AVAILABLE AT

About

  • About us
  • Career
  • ISMS Policy
  • Privacy Policy
  • Terms of Use
  • License Policy
  • Refund Policy
  • End User License Agreement

RESOURCES

  • Blog
  • Articles
  • Product Videos
  • Knowledge Base
  • Case Studies
  • Whitepapers
  • Software Catalog

NEWS & EVENTS

  • News
  • Events

PARTNERS

  • Affiliates
  • Resellers
  • Distributors

Useful Links

  • Contact Us
  • Support
  • Special Offers
  • Student Discounts
  • Awards & Reviews
  • Downloads
  • Store
  • Sitemap
Follow Us

Stellar & Stellar Data Recovery are Registered Trademarks of Stellar Information Technology Pvt. Ltd. © Copyright 2022 Stellar Information Technology Pvt. Ltd. All Trademarks Acknowledged.

DMCA.com Protection Status
We use cookies on this website. By using this site, you agree that we may store and access cookies on your device Read More Got it!