🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #1360

Re: Compacting Database

#1360
From: Viatcheslav V. Vassiliev
Date: Mon, 26 Jul 2004 17:25
57 lines
2480 bytes
When compacting Access db it must be disconnected. Compact always into
another file. Later you may delete initial file and copy new file into its
place.

Import "Microsoft Jet and Replication Objects 2.x Library".

#include <JRO_TLB.h>
...
void __fastcall TForm1::Button1Click(TObject *Sender)
{
 IJetEngine * JetEngine = NULL;
 CoCreateInstance(CLSID_JetEngine, NULL, CLSCTX_INPROC_SERVER,
  IID_IJetEngine, (void**) &JetEngine);
 try
 {
  WideString Source = "Provider=Microsoft.Jet.OLEDB.4.0;"
   "Data Source=C:\\Test\\Test.mdb;";
  WideString Dest = "Provider=Microsoft.Jet.OLEDB.4.0;"
   "Data Source=C:\\Test\\Compacted.mdb;";

  JetEngine->CompactDatabase(Source.c_bstr(), Dest.c_bstr());
 }
__finally
 {
  JetEngine->Release();
 }
}

Compact will also repair database.

//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)


"Kim Utley" <kim@simsware.com> �������/�������� � �������� ���������:
news:41052d23$1@newsgroups.borland.com...
> RE: BCB 6 and TADO... Objects
>
> Hi All,
>
> Can anyone provide a simple method for compacting a Microsoft Access
> database file using TADO objects?
>
> I've looked at the MSDN website and saw a utility they provide but am
> looking for a 'built-in' method to use within my application.
>
> Kindest Regards,
>
>
> Kim L. Utley
>
>
Technical Details
Message-ID: <41053e82@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <41052d23$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,b011e14d990002e1
X-Google-Attributes: gid10698b,public
X-Google-Language: ENGLISH,ASCII
From: "Viatcheslav V. Vassiliev" <support@oledbdirect.com>
Newsgroups: borland.public.cppbuilder.database.ado
References: <41052d23$1@newsgroups.borland.com>
Subject: Re: Compacting Database
Date: Mon, 26 Jul 2004 21:25:23 +0400
Lines: 59
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 213.234.218.42
Message-ID: <41053e82@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1090862722 213.234.218.42 (26 Jul 2004 10:25:22 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail