Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Compactar bd Access 2003 desde Vb

49 views
Skip to first unread message

Diego Luis Pinzón Barrera

unread,
Jun 2, 2006, 12:59:40 AM6/2/06
to
Amigos estoy desarrollando un programa en Visual Basic 6 el cual conecta a
una BD Access 2003, Es posible compactar la base de datos desde visual
basic, tal como se hacia con DAO.

Agradezco la ayuda que me puedan brindar.


Atentamente,

Diego Pinzón


Morgan

unread,
Jun 2, 2006, 1:10:32 AM6/2/06
to
The following listings demonstrate how to compact a database.

Note Use JRO, not ADO, to compact a database.

DAO

Sub DAOCompactDatabase()

' Make sure there isn't already a file with the
' name of the compacted database.
If Dir(".\NewNorthWind.mdb") <> "" Then Kill ".\NewNorthWind.mdb"

' Basic compact - creating new database named newnwind
DBEngine.CompactDatabase ".\NorthWind.mdb", ".\NewNorthWind.mdb"

' Delete the original database
Kill ".\NorthWind.mdb"

' Rename the file back to the original name
Name ".\NewNorthWind.mdb" As ".\NorthWind.mdb"

End Sub

JRO

Sub JROCompactDatabase()

Dim je As New JRO.JetEngine

' Make sure there isn't already a file with the
' name of the compacted database.
If Dir(".\NewNorthWind.mdb") <> "" Then Kill ".\NewNorthWind.mdb"

' Compact the database
je.CompactDatabase "Data Source=.\NorthWind.mdb;", _
"Data Source=.\NewNorthWind.mdb;"

' Delete the original database
Kill ".\NorthWind.mdb"

' Rename the file back to the original name
Name ".\NewNorthWind.mdb" As ".\NorthWind.mdb"

End Sub

The JRO CompactDatabase method takes two connection strings, which indicate
the source database and destination database respectively. See the JRO
online Help for more information on the JRO CompactDatabase method.

In addition to defragmenting or repairing your database, CompactDatabase can
also be used to change the database password, convert the database from an
older Microsoft Jet version to a new version, to encrypt or decrypt the
database, or to change the locale of the database. Note that CompactDatabase
will automatically convert older databases to the current version, unless
you use the Jet OLEDB:Engine Type property in the destination database
parameter.

--
Saludos ... Morgan 8-)
DGPPTB ...Cancún, Quintana Roo, México
PD. Que mueran las "k's", No respondo a quien abuse del uso de esta al
escribir

0 new messages