您的位置 首页 趣闻

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

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

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




免责声明:文章内容不代表本站立场,本站不对其内容的真实性、完整性、准确性给予任何担保、暗示和承诺,仅供读者参考,文章版权归原作者所有。如本文内容影响到您的合法权益(内容、图片等),请及时联系本站,我们会及时删除处理。

作者: dawei

【声明】:第七手机网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。

为您推荐

敢为天下后,OPPO Find N折叠屏的底气何在?

聊起OPPO,给我的第一印象就是本分,而在刚刚发布的OPPO Find N折叠屏手机上,我看到的是OPPO敢为天下后的底气。 当大家还沉浸在前一天发布的马里亚纳MariSilicon X影像NPU芯片时,OPPO又在12月15日推出了旗下首款折叠屏手机产品OPPO Find N。这是一款传闻已

OPPO Find N展开一刻,两大创新技术打破折痕路上意难平

荣耀发布了荣耀60系列的新品,特别是荣耀60 Pro的5000万像素超感知AI前置镜头和1亿像素超清后置主摄,是生活和游玩记录的好帮手。多镜录像功能在荣耀50系列上就已开始引入,在荣耀60系列上还新增了AI手势识别,Vlog隔空换镜这一创新功能,对拍摄Vlog来说相当

深扒天玑9000,发冲高关键年产品底气怎样?

联发科的天玑9000自公布以来,以过硬的技术实力迅速冲上了包括微博热搜在内的各类话题平台,吹响了冲击旗舰的号角。手机芯片进入4nm时代,arm推出面向未来十年的v9架构,5G技术R16即将商用,内存技术在升级面对全产业大跃进之势,联发科的天玑也迎来了上升的

想拍更远?汇总今年搭载潜望式长焦摄像头的手机

部分手机摄影发烧友已不再满足普通的2x长焦摄像头,他们需要拍的更远,画质也不能妥协,于是能拍更远的潜望式长焦摄像头就应运而生了。不过当镜头焦距上去了,后置镜头模组的厚度就难以控制,如果强行塞下更长焦段的镜头,模组厚度将达到1~2cm,这样的手机估

像素并非越高越好,为何5000万像素手机镜头倍受青欢迎

500万、800万、1200万像素,智能手机摄像头像素在早年发展的步伐相对还是比较缓慢,近来2000万、4800万、6400万、1.08亿像素接踵而来,手机摄像头的像素规格呈现出十分迅猛的迭代更新速度。然而在2019年首推量产1.08亿像素的智能手机后,至今手机上单颗传感

返回顶部