您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

怎样经由ADO来压缩Microsoft Access数据库

2024/4/21 0:21:50发布15次查看
howto: compacting microsoft access database via ado -------------------------------------------------------------------------------- the information in this article applies to: activex data objects (ado), versions 2.1, 2.5, 2.6 microsoft o
howto: compacting microsoft access database via ado
--------------------------------------------------------------------------------
the information in this article applies to:
activex data objects (ado), versions 2.1, 2.5, 2.6
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 pathsif 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 kbjet kbprovider kbvbp600 kbvc kbgrpdsvcdb kbgrpdsmdac kbdsupport kbado250 tslic_tslic
kbado260
issue type : kbhowto
technology : kbauddeveloper kbadosearch kbado210 kbado250 kbado260 kboledbsearch kboledbprovjet400
kboledbprovsearch
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product