Posts

Showing posts from February, 2013

Programmatically Compact and Repair Access Example

string connectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;
                            Data Source=" + mainPath + @";
Jet OLEDB:Engine Type=5;
                            Jet OLEDB:Database Password=XXX;";
string compactedNewFilePathAndName = mainPath.Replace(".accdb", "_TEMP.accdb");
CompactAndRepair.CompactAccessDB(connectionString, compactedNewFilePathAndName, mainPath);


--------------------
--------------------

classCompactAndRepair
{
///<summary>
/// MBD compact method (c) 2004 Alexander Youmashev
/// !!IMPORTANT!!
/// !make sure there's no open connections
/// to your db before calling this method!