Compressing An Access Database File From VB 
Author Message
 Compressing An Access Database File From VB

Hey All,

    Can anyone tell me how to compress an Access database file (mdb) within
VB?  This is my first attempt at using MDB files in VB and it appears that
the database size does not change when records are deleted.  I am using the
Data control to access the database file.  I can use Access to compress the
file and the size diminishes.  Any help or ides would be greatly
appreciated.

Thanks,
Leon



Sun, 03 Aug 2003 13:34:05 GMT  
 Compressing An Access Database File From VB
Oooops..... I meant compacting not compressing.

Leon


Quote:
> Hey All,

>     Can anyone tell me how to compress an Access database file (mdb)
within
> VB?  This is my first attempt at using MDB files in VB and it appears that
> the database size does not change when records are deleted.  I am using
the
> Data control to access the database file.  I can use Access to compress
the
> file and the size diminishes.  Any help or ides would be greatly
> appreciated.

> Thanks,
> Leon



Sun, 03 Aug 2003 14:20:49 GMT  
 Compressing An Access Database File From VB
Leon,
make sure you have a reference to the DAO library (should be there as you
are using Access from VB), and in code create an instance of DBEngine. It
has a CompactDatabase method
E.g:

Dim DB as New DAO.DBEngine
DB.CompactDatabase "MYDB.MDB", "NEWDB.MDB"
Kill "MYDB.MDB"
Name "NEWDB.MDB" as "MYDB.MDB"

Thomas



Quote:
> Hey All,

>     Can anyone tell me how to compress an Access database file (mdb)
within
> VB?  This is my first attempt at using MDB files in VB and it appears that
> the database size does not change when records are deleted.  I am using
the
> Data control to access the database file.  I can use Access to compress
the
> file and the size diminishes.  Any help or ides would be greatly
> appreciated.

> Thanks,
> Leon



Sun, 03 Aug 2003 16:29:37 GMT  
 Compressing An Access Database File From VB
If youre using ADO rather than DAO, use the Jet replication Object (jro).

HTH
steve.


Quote:
> Hey All,

>     Can anyone tell me how to compress an Access database file (mdb)
within
> VB?  This is my first attempt at using MDB files in VB and it appears that
> the database size does not change when records are deleted.  I am using
the
> Data control to access the database file.  I can use Access to compress
the
> file and the size diminishes.  Any help or ides would be greatly
> appreciated.

> Thanks,
> Leon



Sun, 03 Aug 2003 20:51:14 GMT  
 Compressing An Access Database File From VB
Works great, thanks.


Quote:
> Leon,
> make sure you have a reference to the DAO library (should be there as you
> are using Access from VB), and in code create an instance of DBEngine. It
> has a CompactDatabase method
> E.g:

> Dim DB as New DAO.DBEngine
> DB.CompactDatabase "MYDB.MDB", "NEWDB.MDB"
> Kill "MYDB.MDB"
> Name "NEWDB.MDB" as "MYDB.MDB"

> Thomas



> > Hey All,

> >     Can anyone tell me how to compress an Access database file (mdb)
> within
> > VB?  This is my first attempt at using MDB files in VB and it appears
that
> > the database size does not change when records are deleted.  I am using
> the
> > Data control to access the database file.  I can use Access to compress
> the
> > file and the size diminishes.  Any help or ides would be greatly
> > appreciated.

> > Thanks,
> > Leon



Mon, 04 Aug 2003 00:50:36 GMT  
 Compressing An Access Database File From VB
Leon

This does what you want.
In your VB program include :-

CompactDatabase "c:\database\bigdb.mdb" , "c:\database\smallerdb.mdb", , ,
";pwd=" & "password"
Kill "c:\database\bigdb.mdb"
Name "c:\database\smallerdb.mdb" As "c:\database\bigdb.mdb"

Couple of notes :-

The database must not be open by another application or MS Access other wise
error 3356 occurs.
The pwd is optional but I do protect my databases.
The kill command deletes the original file and you rename the new database.
This is a lot safer than doing the compression to the original filename.

Hope this helps

Duncan


Quote:
> Hey All,

>     Can anyone tell me how to compress an Access database file (mdb)
within
> VB?  This is my first attempt at using MDB files in VB and it appears that
> the database size does not change when records are deleted.  I am using
the
> Data control to access the database file.  I can use Access to compress
the
> file and the size diminishes.  Any help or ides would be greatly
> appreciated.

> Thanks,
> Leon

  --------== Posted Anonymously via Newsfeeds.Com ==-------
     Featuring the worlds only Anonymous Usenet Server
    -----------== http://www.newsfeeds.com ==----------


Thu, 07 Aug 2003 23:26:21 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Compressing Access databases from within VB 5.0

2. Compressing Access files from within VB code

3. Sample Code Needed to Compress a MS Access file from code in a VB 6 program

4. MS Access database compress with VB6

5. Compressed bitmaps in Access Database

6. Compressing an Access database using ADO

7. Compressing an access database in ADO 2.5

8. Compressing access file?

9. Access File (mdb) Compress

10. How repair and compress Access MDB from VB ?

11. Compressing files (ZIPing) from VB application

12. How do I use CODECs to compress a wave file in VB.

 

 
Powered by phpBB® Forum Software