Gracias por invertir su tiempo en esta consulta. Mi problema básicamente es el
siguiente:
Tengo una aplicación que utiliza una Base de Datos Microsoft Access (la
aplicación es pequeña); pero cuando se cargan registros en forma masiva el
archivo .MDB se hace muy grande. Si usted compacta la BD utilizando la opción
existente en el menú de Access el mismo pasa de 50 MB a 1.5 MB.
Con objetos DAO, existía un método llamado "CompactDatabase" que realiza la
función de compactar la Base de Datos desde Visual Basic; pero no he podido
determinar si existe un método similar con objetos ADO. Si usted conoce como
hacerlo con objetos ADO; le agradezco mucho su respuesta. Muchas Gracias!
Aquí tienes algo chulo, que a veces funciona y otras no, no por el código en
si ya que realmente la línea que compacta es
DBEngine.CompactDatabase Me.Archivo, Me.Archivo & "1"
El resto es floritura.
Si eres un habitual del Access, prueba en la news
microsoft.public.es.access
y esta otra en la news.teleline.es
es.comp.bd.ms-access
Suerte.
--
Un Saludo y Feliz Navidad
McPegasus
Valencia, España
mcpe...@hotmail.com
----------------------------------------------------------------------------
----
The information in this article applies to:
ActiveX Data Objects (ADO), version 2.1
Microsoft OLE DB Provider for Jet, version 4.0
----------------------------------------------------------------------------
----
SUMMARY
Although ADO specification does not provide objects to compact or repair
Microsoft Access databases, this capability can be achieved by using the ADO
extension: Microsoft Jet OLE DB Provider and Replication Objects (JRO). This
capability was implemented for the first time in the JET OLE DB Provider
version 4.0 (Msjetoledb40.dll) and JRO version 2.1 (Msjro.dll). These DLL
files are available after the install of MDAC 2.1. You can download the
latest version of MDAC from the following Web site:
Universal Data Access Web Site
MORE INFORMATION
To repair and compact an Access database using ADO, MDAC 2.1 or later must
be properly installed on the computer. The following are the main steps to
compact a Microsoft Access database using Visual Basic and Visual C++:
Visual Basic: Compacting an Access Database via ADO
In the Visual Basic IDE, on the Projects menu, click References.
Add Microsoft Jet and Replication Objects X.X library, where (X.X is greater
than or equal to 2.1).
Add the following lines of code to Visual Basic, replacing the data source
and destination database paths if needed:
Dim jro As jro.JetEngine
Set jro = New jro.JetEngine
jro.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=d:\\nwind2.mdb", _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\\abbc2.mdb;Jet OLEDB:Engine
Type=4"
NOTE: In DAO 3.60, the RepairDatabase method is no longer available. The
above code shows the use of the CompactDatabase method. This method replaces
the DAO 3.5 RepairDatabase method.
Visual C++: Compacting an Access Database via ADO
Besides #import, the Msado15.dll (MDAC2.1), add the following #import
statement to generate the wrapper classes for JRO to your .cpp classes
(alternatively, you can generate the wrapper classes more efficiently by
using the no_implementation and implementation_only attributes of the
#import pre-processor statement):
#import "C:\PROGRAM FILES\COMMON FILES\System\ado\MSJRO.DLL" no_namespace
Add the following (specifying your own source and destination database
paths) to the .cpp file where you want to compact the database:
...
try
{
IJetEnginePtr jet(__uuidof(JetEngine));
jet->CompactDatabase("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=d:\\nwind2.mdb", "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=d:\\abbc.mdb;Jet OLEDB:Engine Type=4");
}
catch(_com_error &e)
{
::MessageBox(NULL, (LPCTSTR)e.Description( ), "", MB_OK) ;
}
NOTE: The Jet OLEDB:Engine Type=4 is only for Jet 3.x format MDB files. If
this value is left out, the database is automatically upgraded to the 4.0
version (Jet OLEDB:Engine Type=5). See the following table for appropriate
values for Jet OLEDB:Engine Type:
Jet OLEDB:Engine Type Jet x.x Format MDB Files
1 JET10
2 JET11
3 JET2X
4 JET3X
5 JET4X
REFERENCES
For additional information, please see the following article in the
Microsoft Knowledge Base:
Q230496 Compacting Microsoft Access database via OLE DB
Additional query words: CompactDatabase RepairDatabase reindex
Keywords : kbADO210 kbDatabase kbJET kbProvider kbVBp600 kbVC kbGrpVCDB
kbGrpMDAC
Version : WINDOWS:2.1,4.0
Platform : WINDOWS
Issue type : kbhowto
Technology :
Last Reviewed: August 11, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.
----------------------------------------------------------------------------
----
Send feedback to MSDN.Look here for MSDN Online resources.
--
=================
Saludos,
Norman ;-)
...
"Luis Diego" <lma...@bncr.fi.cr> wrote in message
news:3e8301c05e25$f0468c10$48862ecf@cpmsftngxa08...