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

How to compress and repair Access databses

   

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: 6/14/2008 7:30 AM
Views: 1147
Votes: 1
Rating:   from 5.00 Points

Your Rating:

bookmark this
 

There is no comment for this topic.
Language:

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