En  Fa
softprojects.org
Discovering: Tips & Tricks  > Languages  > Delphi Tips  > How to compress and repair Access databses
 

Articles

 

 

Tips and Tricks

 


 

How to compress and repair Access databses

Print version  

How to compress and repair Access databses

Description

This method shows an delphi implementation of an access database feature that able us to compress or repair databases.

Delphi code

uses
  ComObj;

function CompactAndRepair(DB: string): Boolean; {DB = Path to Access Database}
var
  v: OLEvariant;
begin
  Result := True;
  try
    v := CreateOLEObject('JRO.JetEngine');
    try
      V.CompactDatabase('Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+DB,
                        'Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+DB+'x;Jet OLEDB:Engine Type=5');
      DeleteFile(DB);
      RenameFile(DB+'x',DB);
    finally
      V := Unassigned;
    end;
  except
    Result := False;
  end;
end;

Details
      
Writer: Salar Khalilzadeh
Date Sent: 3/16/2008 7:30 AM
Views: 525
Votes: 1
Rating: 5.00 Points from 5.00 Points

Your Rating:
bookmark this
 

There is no comment for this topic.

Language:

Copyright © 2008 SoftProjects.org | About | Valid XHTML | CSS