Article View: borland.public.cppbuilder.database.ado
Article #5308Re: Final Question on Compacting Access Databases
From: Rick Golden
Date: Tue, 19 Jun 2001 17:02
Date: Tue, 19 Jun 2001 17:02
144 lines
4767 bytes
4767 bytes
The following code works for me but it is not an Access2000 file.......
Haven't tested it yet with it...
It looks very similar to your code but maybe something will help
bye!
file://---------------------------------------------------------------------
------
#include <vcl.h>
#pragma hdrstop
#include "FCompactBD.h"
#include "JRO_TLB.h"
file://---------------------------------------------------------------------
------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
file://---------------------------------------------------------------------
------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
file://---------------------------------------------------------------------
------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
try
{
TCOMIJetEngine aa;
aa = CoJetEngine::Create();
WideString sSource = WideString("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=d:\\YOURBD.mdb;Jet OLEDB:Database Password=\"YOURPASSWORD\"");
WideString sDest = WideString("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=d:\\test.mdb;Jet OLEDB:Engine Type=4;Jet OLEDB:Database
Password=\"YOURPASSWORD\"");
HRESULT nn = aa.CompactDatabase(sSource, sDest);
if (nn == S_OK)
ShowMessage("ADS");
}
catch(Exception &e)
{
::MessageBox(NULL, e.Message.c_str(), "", MB_OK) ;
}
}
file://---------------------------------------------------------------------
------
Mike Collins <mcollins@tynetec.demon.co.uk> wrote in message
news:3b2f3c53_1@dnews...
> Does anyone know if it IS POSSIBLE to compact an MS Access 2000 database
> when connecting using ADO and the MS Jet Engine 4.
>
> I've spent the last week trying to compact an Access database, I've been
to
> every site on the net which has a reference to this, and I've posted
> numerouse questions. Nigal Jones pointed me in the direction of using the
> Import Type Libaray to access the msjro.dll. I've done all this, pass
what
> I think are the correct parameter, compiled and run. And the result is
> NOTHING. Please, please, please, if anyone knows how to achieve this in
> C++Builder (not delphi), could you please post me. My code is below if
> anyone cares to have a look:
>
> file://Project.cpp
> USE("C:\Program
> Files\Programming\Borland\CBuilder5\Imports\JRO_TLB.h", File);
>
> file://Main.cpp#pragma package(smart_init)
> #pragma link "JRO_TLB"
> #pragma resource "*.dfm"
>
> TForm1 *Form1;
>
> void __fastcall TForm1::BitBtn1Click(TObject *Sender)
> {
> try
> {
> jet = CoJetEngine::Create();
> jet->CompactDatabase(
>
> WideString"Provider=Microsoft.Jet.OLEDB.4.0;DatSource=c:\\bob.mdb"),
>
> WideString("Provider=Microsoft.Jet.OLEDB.4.0;Dat Source=c:\\biff.mdb;Jet
> OLEDB:Engine Type=5"));
> }
> catch (...)
> {
> ShowMessage("Error");
> }
> }
>
> file://Main.h
> #ifndef MainH
> #define MainH
> #include "JRO_TLB.h"
> #include <Classes.hpp>
> #include <Controls.hpp>
> #include <StdCtrls.hpp>
> #include <Forms.hpp>
> #include <Buttons.hpp>
> #include <Db.hpp>
>
> class TForm1 : public TForm
> {
> __published:
> TBitBtn *BitBtn1;
> void __fastcall BitBtn1Click(TObject *Sender);
> private:
> TCOMIJetEngine jet;
> public:
> __fastcall TForm1(TComponent* Owner);
> };
>
>
file://---------------------------------------------------------------------
-----
> -
> extern PACKAGE TForm1 *Form1;
>
>
file://---------------------------------------------------------------------
-----
> -
> #endif
>
>
>
>
>
Technical Details
Message-ID:
<3b2f854d_1@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!newsfeed.google.com!sn-xit-03!sn-xit-02!supernews.com!nntp-relay.ihug.net!ihug.co.nz!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnewsReferences:
<3b2f3c53_1@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10698b,ec9907cfc07dfcb4 X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2001-06-19 10:27:24 PST Reply-To: "Rick Golden" <GoldenRick@hotmail.com> From: "Rick Golden" <GoldenRick@hotmail.com> Newsgroups: borland.public.cppbuilder.database.ado References: <3b2f3c53_1@dnews> Subject: Re: Final Question on Compacting Access Databases Date: Tue, 19 Jun 2001 13:02:39 -0400 Lines: 146 Organization: Gold X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2314.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 NNTP-Posting-Host: 198.168.250.105 Message-ID: <3b2f854d_1@dnews> X-Trace: dnews 992970061 198.168.250.105 (19 Jun 2001 10:01:01 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!newsfeed.google.com!sn-xit-03!sn-xit-02!supernews.com!nntp-relay.ihug.net!ihug.co.nz!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews