如题

解决方案 »

  1.   

    http://support.microsoft.com/default.aspx?scid=KB;en-us;q230501
    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 
      

  2.   

    加入以下语句
    #import "C:\PROGRAM FILES\COMMON FILES\System\ado\MSJRO.DLL" no_namespace 
    后生成的接口描述头文件出现这样的问题
        __missing_type__ ConflictTables;
    错误:'__missing_type__': missing storage-class or type specifiers
    请问这是怎么回事?怎么解决?