Compact an Access 2000 DB using ADO in VC?

Compact an Access 2000 DB using ADO in VC?

Post by John M. Dresche » Wed, 10 May 2000 04:00:00



How do I compact an Access 2000 DB in Visual C++ using ADO? I'm using the
import "msado15.dll" call.
Thanks in advance,

--
John M. Drescher
Systems Analyst / Programmer III
University of Pittsburgh Radiology Department
http://www.geocities.com/SiliconValley/Haven/1654/

 
 
 

Compact an Access 2000 DB using ADO in VC?

Post by Jason Turi » Thu, 11 May 2000 04:00:00


did you ever get an answer to this question. i'm trying to do the same thing
(w/an Access 97 db)

thanks,
-j


>How do I compact an Access 2000 DB in Visual C++ using ADO? I'm using the
>import "msado15.dll" call.
>Thanks in advance,

>--
>John M. Drescher
>Systems Analyst / Programmer III
>University of Pittsburgh Radiology Department
>http://www.geocities.com/SiliconValley/Haven/1654/



 
 
 

Compact an Access 2000 DB using ADO in VC?

Post by Robert van Gen » Thu, 11 May 2000 04:00:00


here's some sample code for doing it with access 97; it will
probably work with 2000 as well.

note that you can't compact "in place" -- you have to
specify a destination file. if you want to compact in place,
you have to move the file first, then compact it back to its
original path, then delete the original.

CString c1, c2;
c1.Format("Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine
Type=4;Data Source=%s", src_path);
c2.Format("Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine
Type=4;Data Source=%s", dst_path);
_bstr_t c1_bstr(c1);
_bstr_t c2_bstr(c2);

try {
  IJetEnginePtr jet;
  jet.CreateInstance(__uuidof(JetEngine));
  jet->CompactDatabase(c1_bstr, c2_bstr);

Quote:}

catch (...) {
  return FALSE;

Quote:}

hope that helps,

r


> did you ever get an answer to this question. i'm trying to do the same thing
> (w/an Access 97 db)

> thanks,
> -j



> >How do I compact an Access 2000 DB in Visual C++ using ADO? I'm using the
> >import "msado15.dll" call.
> >Thanks in advance,

> >--
> >John M. Drescher
> >Systems Analyst / Programmer III
> >University of Pittsburgh Radiology Department
> >http://www.geocities.com/SiliconValley/Haven/1654/


 
 
 

1. How to compact an access-db using ADO?

Dear Marc,

Ado does not support Compact or Encrypt Access Database.

You have to use JRO method in VB-6 as under:

Before using following code, make sure you have selected :

Microsoft Jet and Replication Objects 2.5 Library in References from
Projects-References Menu of VB-6.

This example demonstrates how to compact and encrypt a database with the
CompactDatabase method.

Public Sub CompactAndEncrypt()

   Dim je As New JRO.JetEngine

   ' Make sure that a file doesn't exist with the name of
   ' the compacted database.
   If Dir("C:\Program Files\Microsoft Office\" & _
      "Office\Samples\Northwind2.mdb") <> "" Then Kill _
      "C:\Program Files\Microsoft Office\Office\Samples\Northwind2.mdb"

   ' Compacts and encrypts version Northwind database.
   je.CompactDatabase _
   "Provider=Microsoft.Jet.OLEDB.4.0;" & _
      "Data Source=C:\Program Files\Microsoft Office\" & _
      "Office\Samples\Northwind.mdb", _
   "Provider=Microsoft.Jet.OLEDB.4.0;" & _
      "Data Source=C:\Program Files\Microsoft Office\" & _
      "Office\Samples\Northwind2.mdb;" & _
   "Jet OLEDB:Encrypt Database=True"

End Sub

Best Regards,

Luqman


2. Read AsMemo ?

3. Compact a Access 2002 database with ADO vc++

4. DTS to maintain a persistent copy of an Oracle Table

5. Compact Access DB using ADO & VB6

6. DTS -- Step precedence

7. How to compact an access-db using ADO?

8. Q about vb6 exe file

9. Can't access db in Access 2000 using ADO

10. Multiuser Access 2000 DB using ADO - Locking Problem

11. Compact Access 2000 DB with VB6 Code

12. ADO and Access 2000 compact and repair command???

13. How to COMPACT Access 2000 database with ADO