Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to compact an Access database using Delphi 5.0 Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
compact an Access database using Delphi 5.0 16-Jan-03
Category
Database Others
Language
Delphi 5.x
Views
138
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Lou Adler 

How to compact and repair MS Access 2000 (Jet Engine 4) during run time using 
Delphi 5?

Answer:

Usually the size of MS Access keep growing fast by time because of it’s internal 
caching and temporary buffering, which in over whole effect the performance, space 
required for storing, and backing-up (if needed).  The solution is to compact it 
from Access menus (Tools – Database Utilities – Compact and Repair Database) or to 
do that from inside your Delphi application.
1   
2   function CompactAndRepair(sOldMDB: string; sNewMDB: string): Boolean;
3   const
4     sProvider = 'Provider=Microsoft.Jet.OLEDB.4.0;';
5   var
6     oJetEng: JetEngine;
7   begin
8     sOldMDB := sProvider + 'Data Source=' + sOldMDB;
9     sNewMDB := sProvider + 'Data Source=' + sNewMDB;
10  
11    try
12      oJetEng := CoJetEngine.Create;
13      oJetEng.CompactDatabase(sOldMDB, sNewMDB);
14      oJetEng := nil;
15      Result := True;
16    except
17      oJetEng := nil;
18      Result := False;
19    end;
20  end;
21  
22  //Example :
23  
24  if CompactAndRepair('e:\Old.mdb', 'e:\New.mdb') then
25    ShowMessage('Successfully')
26  else
27    ShowMessage('Error…');


Important Notes:
Include the JRO_TLB unit in your uses clause.
Nobody should use or open the database during compacting.
If the compiler gives you an error on the JRO_TLB unit follow these steps:
Using the Delphi IDE go to Project – Import Type Library.
Scroll down until you reach “Microsoft Jet and Replication Objects 2.1 Library”.
Click on Install button.
Recompile a gain.

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC