Article View: borland.public.cppbuilder.database.ado
Article #1765Re: Compact an Access database
From: Viatcheslav V. Vassiliev
Date: Mon, 23 Feb 2004 10:50
Date: Mon, 23 Feb 2004 10:50
49 lines
2277 bytes
2277 bytes
When compacting Access db it must be disconnected.
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)
"Steve Aletto" <steve_alettoANTI@SPAMhotmail.com> �������/�������� �
�������� ���������: news:4039bd8c@newsgroups.borland.com...
> Hi all,
>
> how to compact an Access database? I specify that such
> database could be open by other applications (or by the
> application itself, another thread for example).
>
> Thanks in advance,
>
> Steve.
>
>
Technical Details
Message-ID:
<4039db00$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4039bd8c@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 10698b,f68b0297659fe81f X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2004-02-23 03:09:34 PST From: "Viatcheslav V. Vassiliev" <support@oledbdirect.com> Newsgroups: borland.public.cppbuilder.database.ado References: <4039bd8c@newsgroups.borland.com> Subject: Re: Compact an Access database Date: Mon, 23 Feb 2004 13:50:42 +0300 Lines: 51 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 213.234.218.42 Message-ID: <4039db00$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1077533440 213.234.218.42 (23 Feb 2004 02:50:40 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail