????? ??????? ADOX ?? C++ ??? ??? ??? ????? ?????? Jet ????? ??? ????? ?????? ????? Jet 4.0 ????

?????? ????????? ?????? ?????????
???? ???????: 321328 - ??? ???????? ???? ????? ????? ??? ???????.
??? ????? ??? ???????. ????? "??? ??" ??? ??? ??????? ??? ????.
????? ???? | ?? ????

??????

???? ??? ??????? ????? ??????? ?????? ?????? ?????? ActiveX ???? ????? ???????? ? ?????? (ADOX) ?? Visual C++ ?????? ????? ?????? Jet ????? ???????? ?????? ?? ????? ?????? Jet ????? ?????. ???? ??? ?????? ????? ???????? ??????? ???? ??? ????????? ?? ADOX ?? Visual C++:
  • ????? ??????? ADOX ?? Visual C++ ??? ????? ????? ?????? Jet
  • ????? ?????? ??? ????? ??????? ?? ????? ??????
  • ????? ?????? ??? ?????? ??????? ????? ??? ?? ??? ??????? ?????
  • ????? ??????? ????? ????? ADOX ?????? ??????? ????????
  • ????? ??????? ??????? ???????? ???? Jet OLE DB ??? ????? ???? ?????
  • ????? ??????? ADO ?? ?????? ?? ADOX ??? ???????? ?? ????? ?????? ???? ??? ???
  • ????? ??? ???? ?? ????? ?????? Jet

??????? ????

?????? ??????? CompactDatabase ???? ????? ???????? Jet (JRO) reveals ?? ???? ??????? ?? efectively ????? ???? ??? ????? Jet 4.0 ??? ??? ?????? ?????? ?? Access 2.0 ?? ?? ????? Access 95. ??? ??? ??? ????? ???? ???? ?? ?????? ?????? Access 2.0 ?? Access 95 ??? ????? Jet 4.0 ???????? ??????? CompactDatabase ?????? JRO ? Access 2000 ?? Access 2002 ????? ????? ??? ????? ????????. ??? ??????? ?? ??? ??? ????????? ?? Microsoft. ???? ?? ???????? JRO ?? ???? ???? ??? ?? Jet 4.0 ? Jet 3.5 x ????? ????? ????????.

????? ????? ?????? Jet ?????? (???? ?? ????? Jet 3.5) ? ?????? ADOX ????? ????? ?????? ????? ????? 4.0 ???? ???? ???????. ???? ???????? ???????? ??????? ????? ?????? ????. ??? ?? ????? ???? ??? ?? ????? ?????? ?? ???????????? ?????? ??? ???????? ???????? ????? ?????? ??????. ??? ??????? ??? ??????? ? ?? ???? ?????? ???? ?? ????? ???????? ??????. ?????? ??? ??????? ?????? ??? ??? ???????? ???? ????? ADOX ??? ???? "????? MSDN".

??? ????????? ???????? ??????? ?? ????? C++ ??? ?? ????? ???????:

??????: ?? ???? ???? ????? ?? ??? ?? ????????? ???????? ??? ???????? ??? ????? #import ??????.
#import "c:\Program Files\Common Files\system\ado\msado15.dll" 
#import "c:\Program Files\Common Files\system\ado\msadox.dll"

#include <iostream>
using namespace std;

void main()
{
	
   CoInitialize(NULL);
	
   //ADO Connection Object pointers for source and destination.
   ADODB::_ConnectionPtr SourceCon = NULL;
   ADODB::_ConnectionPtr DestCon = NULL;

   //ADOX Catalog object pointers for source and destination.
   ADOX::_CatalogPtr DestDB = NULL;
   ADOX::_CatalogPtr SourceDB = NULL;
	
   //Connection string. 
   _bstr_t SrcConnectionString(L""), DestConnectionString(L""), SourceDBLocation(L"");

   ADOX::_TablePtr linkedTbl = NULL;
   ADOX::_ColumnPtr f = NULL;
   ADOX::_TablePtr DestTable = NULL;

   try{

         SourceDBLocation = (L"C:\\JET30FormatDB.mdb");
         //Per Q299484, you must use ODBC Provider to avoid alphabetical ordering.
         SrcConnectionString = "Driver={Microsoft Access Driver (*.mdb)};"
			"DBQ=" + SourceDBLocation; 

         DestConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;"
			  "Data Source=C:\\JET40FormatDB.mdb;"	;

         SourceCon.CreateInstance(__uuidof(ADODB::Connection));
         SourceCon->Open(SrcConnectionString,"","",-1);
         SourceDB.CreateInstance(__uuidof (ADOX::Catalog));
         //ADOX catalog must have an active ADO connection 
         SourceDB->PutActiveConnection(_variant_t((IDispatch *) SourceCon));
		
         DestDB.CreateInstance(__uuidof (ADOX::Catalog));
		
         //This line creates a Jet database, and throws an exception if it already exists.
         DestDB->Create(DestConnectionString);
         DestCon.CreateInstance(__uuidof(ADODB::Connection));
         DestCon->Open(DestConnectionString,"","",-1);
         DestDB->PutActiveConnection(_variant_t((IDispatch *) DestCon));

         //Get the count of tables in Source Database.
         long x = SourceDB->Tables->Count;
         for (int i = 0; i < x ; i++)
         {
            // Go through each table that is listed as TABLE and not SYSTEM TABLE or ACCESS SYSTEM TABLE.
            if (SourceDB->Tables->Item[(long)i]->Type == _bstr_t(L"TABLE"))
            {
               cout<<"Now copying "<< (LPCSTR)SourceDB->Tables->Item[(long)i]->Name<<endl;
               _bstr_t tblName = SourceDB->Tables->Item[(long)i]->Name;
               //Start creating a table.
               DestTable.CreateInstance(__uuidof(ADOX::Table));
               DestTable->Name = tblName;

               //Get number of columns in Source Table. 
               int cnt = SourceDB->Tables->Item[tblName]->Columns->Count;
				
               //Use ADOX Append method to append all columns to the destination table. 
               for ( int col = 0; col < cnt; col++)
               {
                  f = SourceDB->Tables->Item[tblName]->Columns->Item[(long)col];
                 DestTable->Columns->Append(f->Name,f->Type,f->DefinedSize);
               }
					
               //Finally, append destination table.
               DestDB->Tables->Append( DestTable.GetInterfacePtr());

               //This step is to get the data from source table. 
               //Create a temporary linked table in Destination Database
               //and run "Insert Into mynewTable Select * from LinkedTable".
               linkedTbl.CreateInstance(__uuidof(ADOX::Table));
               linkedTbl->ParentCatalog = DestDB;
               linkedTbl->Name = "TempLink2";
               linkedTbl->Properties->Item["Jet OLEDB:Create Link"]->Value = (long)true;
               linkedTbl->Properties->Item["Jet OLEDB:Link Datasource"]->Value = SourceDBLocation;      
               linkedTbl->Properties->Item["Jet OLEDB:Remote Table Name"]->Value = tblName;
				DestDB->Tables->Append(linkedTbl.GetInterfacePtr());

               DestCon->Execute("Insert into " + tblName + " Select * From TempLink2", NULL, -1);
               //You do not have to keep this linked table around, so you can delete it. 
               DestDB->Tables->Delete("TempLink2");
               DestTable.Release();
               linkedTbl.Release();
            }
            else
            {
               cout <<"Skipping "<< (LPCSTR)SourceDB->Tables->Item[(long)i]->Name <<endl;
            }
			
        } // End of for loop.
				
        DestCon->Close();
        SourceCon->Close();
       }
       catch(_com_error &e)
       {
         _bstr_t bstrSource(e.Source());
         _bstr_t bstrDescription(e.Description());
         cout<< "Source: "<< (LPCSTR)bstrSource <<"\nDescription : " << (LPCSTR)bstrDescription <<endl;
       }
}
				

?????

????? ?? ?????????? ?? ?????? ????? MSDN ?? ???? Microsoft ?????? ??? ?????:
http://msdn2.microsoft.com/en-us/library/default.aspx
?? ???? "?????????" ?? ????? ?????? ?? ????? MSDN ?????? ?????? ??? ????? ????????? ??????:
  \Data Access
    \Microsoft Data Access Components
      \ADO
        \SDK Documentation
          \Microsoft ActiveX Data Objects (ADO)
            \ADO Programmer's Guide
				
?????? ??? ??????? ??????? ???? ??? ???? ????????? ????????? ??????? ?? "????? ??????? ?? Microsoft:
225048INFO: ??????? ????? ?? DAO/Jet ??? ADO/Jet
304322ACC2002: ????? ??????? ADOX "?????? ???????"
230588????? ?????? ? ????? ????? Jet ??????? ADOX ????????
279245FIX: ??? ????? ?????? ????????? ??? ????? ?? ???? ??? ???????? ADOX ??? ????? ?????? Access
304323ACC2002: ????? ??????? ADOX ?????? ??????? SQL ????????
275252ACC2000: ????? ????? ???? ?? ????? ?????? Jet ???? ADOX
252908????? ????? ???? ?? ????? ????? ??? ADOX
230501????? ??? ????? ?????? Microsoft Access ?????? ADO

???????

???? ???????: 321328 - ????? ??? ??????: 28/???? ??????/1435 - ??????: 1.4
????? ???
  • Microsoft Visual Studio 6.0 Enterprise Edition
  • Microsoft ActiveX Data Objects 2.7
????? ??????: 
kbnosurvey kbarchive kbmt kbfile kbhowto KB321328 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????321328

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com