INFO: ??????? ?????? ?????? ActiveX (ADO) ??? #import ?? VC ++

?????? ????????? ?????? ?????????
???? ???????: 169496 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

?? ??? ??????

??????

???? ??????? #import ?? Visual C++ ????? ????? ????? ??????? ?????? OLE. ??? ????????? ?? "?????? ?????? ActiveX" (ADO) ? ???? ????? #import ?????? ??? ???????? ?????? ??. ?????? ??? ??????? ?? ?? ??????? ????????? ?? #import ?? ADO.

??????? ????

??? ?? "????? ????? ???? ?? ???? ?????" ?????? #import

?? ????? ????? OLE ??? ????? ??? ?????? ?????? ???? ?? ??????? ?????? #import. ??? ???? ??????? ???????? ???????? ??????? ?????? ??? ??? ???? ?????? ???? ???? #import ????? OLE ?? instantiates ?????? ??????:

   // Declare smart pointer of Recordset
    _RecordsetPtr     p;

   void main( void )
   {
      // Initialize OLE.
      ::CoInitialize(NULL);

      // Instantiate smart pointer.
      HRESULT hr = p.CreateInstance( __uuidof( Recordset ) );

      ...
   }
				
????? ????????? ???????? ??????? ??? ????? ?? ???? ??? ??? ????? ?????? ??????? ??? ?????. ?????? ?????? ???????? p ?? ????? ???? ????? ???? (?????? virtue ?? ????? uuid ????? ?? ??????):

// Declare & instantiate smart pointer of Recordset
    _RecordsetPtr     p( __uuidof( _Recordset ) );

   void main( void )
   {
      // Initialize OLE
      ::CoInitialize(NULL);

      ...
   }
				
??? p ????? ?????, ??? ????? ??? CoInitialize ?? ???? ?? main(). ????? ????? ??? ?? ????????? ???????? ????????:
struct InitOle {
      InitOle()  { ::CoInitialize(NULL); }
      ~InitOle() { ::CoUninitialize();   }
    } _init_InitOle_;

   // Declare & instantiate smart pointer of Recordset
    _RecordsetPtr     p( __uuidof( _Recordset ) );

   ...
				
???? ????? InitOle ?? ??????? ????? ???? ??? p ? ? ? ?????? ????? OLE ?? ??????? ????? ??. ???? ??? ????? ?? fail-safe ??? ??? ????? ????? ???????:
unhandled ????????? ?? [??????] (KERNEL32.DLL): 0xE06D7363
??????? C++ Microsoft.

????? ??????? #import

?? ????? ?? ??????? ADO ???? ???? ?? ???????? ?? ???? ?? ???? ???? ????? ?????? ??????? ???????. ???? ???????? ???????? ??????? ??????? ??????? ???????? #import ?? Msado10.dll MSADO15.dll:

   #import <msado15.dll>            \ 
   no_namespace                     \ 
  rename( "EOF", "adoEOF" )
				

?????? ?????

???????? ADO ? ?? ????? ??? ?? HRESULT ???? ??? ??????? ?? ????? ADO ?? ???? ??? ?????? ?????? #import ????? ??????? ???? ?? ??? ????? ?????? ????? ADO ??? ???. ????? ??? ?????? ??? ?? "?????? ?????" ???? ????? ????. ?????? ??? ???? ?? ????????? ?????? ?????? ??????? ??????? ?? "????? ??????? ?? Microsoft:

169498INFO: ??????? "??????? ?????" ?? ADO ?? VC ++ ?? #import

ADO ? Dbdaoint.h

????? ??? ADO (?? ???? #import) ? ??? DAO MFC ?? SDK DAO ?? ??? ??????? ???? ??? ???:

  #include <afxdao.h>  // MFC DAO
   // -or-
  #include <dbdao.h>   // DAO SDK

  #import <msado15.dll> no_namespace ...
				

?? ?????? ??????? ????? ???????:

??? C2011: 'EditModeEnum': '?????' ???? redefinition
??? C2011: 'LockTypeEnum': '?????' ???? redefinition
??? C2011: 'FieldAttributeEnum': '?????' ???? redefinition
??? C2011: 'DataTypeEnum': '?????' ???? redefinition
??? C2011: 'ParameterDirectionEnum': '?????' ???? redefinition
??? C2011: 'RecordStatusEnum': '?????' ???? redefinition
????? ???? ??????? ??????? ?? ????? ? ????? ??????? ?? ?? ??? ????? ????? ????? ??? ?? ????? ?? ??? ADO ? ?? ????? ?? ??? DAO. ???? ?????? ?? ???????? ??????? ?????? ??? ???:

  • ?????? ADO DAO ???? ?? ????? .cpp ??????. ???????? ??????? #import ?? ????? # <afxdao.h/dbdao.h> ?? ????? ?????? ????? ?????.
  • ????? ????? #import ?????? ????? ??? ??? ??? ????? ADO. ???? ???? ??? ?????? ??? ????? ????? ??? ??????? ??? ???? ADO ??? ?? ???? ?? ????? ????? ?????. ????? ???? ??? ??? ??????? ADO ???? ??? ???? ????. ????? ?????? ????? ADO ??? ? ????? ??????? DAO. ???? ???? ??? ?? ??? ???? ???? ??????? ??? ????? ????? ADO ??? ??? ADO ?? ???? ????? ?????:

       #include <afxdao.h>
    
          #import <msado15.dll>                            \ 
                  rename_namespace("AdoNS") rename( "EOF", "adoEOF" )
    
          void ADOOnly( void )
          {
              using namespace AdoNS;
    
              _RecordsetPtr   prs;
    
              // Generates Compile Errors:
              CDaoRecordset   rs;
          }
    
          void MixAdoAndDao( void )
          {
              AdoNS::_RecordsetPtr  prs;
    
              // Compiles just fine
              CDaoRecordset   drs;
          }
    						
Msado105.tlh/Msado15.tli dissecting ???????--------------------------------------------

???? #import ????? Msado105.tlh ? Msado15.tli ?????? ?? ????? ??? Msado15.dll. ???? ????? ???? ??? .tlh ??? ???:
  • ????? ? Typedefs ??????
  • Typedef ?????? ?????? ? Declarations
  • ????? ????? ???
??? ??? ?? ????? ?????.

????? ? Typedefs ??????

????? ??? ?????? ? Typedefs ??? ????? ???? ???? ??????? ?? __declspec(uuid("...")) ????? ??? GUID ???? ?? "????? ?????" ????? ? ???????? CoClass ?? ?????.

   ...
   struct __declspec(uuid("00000274-0000-0010-8000-00aa006d2ea4"))
   /* dual interface */ _Connection;
   ...
   struct __declspec(uuid("00000275-0000-0010-8000-00aa006d2ea4"))
   /* interface */ ICADOConnection;
   ...
   struct /* coclass */ Connection;
   ...
				
???? ???? ???????? ??? ??????? ?? ???? ???? ??????? ??????. ????? ??? ??? ????? ???? ??? ??? ADO ?????? ???? ???? ????? ??? ????? ????? ?? coclass.

????????? TypeDef ?????? ??????

?????? ? "?????? ?????" ?????? ???? ?? ??????? ? ???? ???? ???? ???? ???????? ???????:
   ...
   _COM_SMARTPTR_TYPEDEF(_Connection, __uuidof(_Connection));
   ...
   _COM_SMARTPTR_TYPEDEF(ICADOConnection, __uuidof(ICADOConnection));
   ...
				
?????? ?? ???? ???? ???? ?? ??????? ?? ?? coclass ????? ???????.

????? ????? ???

????? ??? ?? ????? ????? ????? ????? ?? ????? ? ??? ????? ????? ?????? ?????? ???????? ?????:

enum CursorTypeEnum
   {
      adOpenUnspecified = -1,
      adOpenForwardOnly = 0,
      adOpenKeyset = 1,
      adOpenDynamic = 2,
      adOpenStatic = 3
   };

   ...

   struct __declspec(uuid("00000274-0000-0010-8000-00aa006d2ea4"))
   _Connection : _ADO
   {
      // 
      // Property data.
      // 
      _declspec(property(get=GetConnectionString,
                         put=PutConnectionString))
      _bstr_t ConnectionString;
      ...

      // 
      // Wrapper methods for error-handling.
      // 
      _bstr_t GetConnectionString ( );
      void PutConnectionString (
          _bstr_t pbstr );
      ...

      // 
      // Raw methods provided by interface.
      // 
      virtual HRESULT __stdcall get_ConnectionString (
          BSTR * pbstr ) = 0;
      virtual HRESULT __stdcall put_ConnectionString (
          BSTR pbstr ) = 0;
      ...
   };
				
?? ??? ????????? ???????? ?????? ?????? ???? "???????? ?????" declspec ??????? ?????? ??? ?????? ???? ?? ?????_???????. ???? ?????? ?????? ?????? ???????? ???? ?? ??????? ?????? #import ? ????? ?????? ??? ????? ?????? ??????? _com_error ??? ?? ??? ???????. ?????? "?????? ???????" ??????? ??????? ?????? ???? ??? ???????? ?????? ???????.

????? ?? ??????? GetConnectionString ?? PutConnectionString ??? ??? ?????? ?????. ??? ?????_??????? ????? ???? ?? ??? ???:

   bstrConnect = SysAllocString( L"DSN=AdoDemo;UID=admin;PWD=sa" );
   p->ConnectionString = bstrConnect;
				


???? ?????? ??? ??????? ?????? GetConnectionString/PutConnectionString ?? ??? Msado15.tli.

????? ????? ????? ????? ???????? ???? ??????? ?? ????????? ???????? ?????? ???? ?????? ?????? ?? ????? ?????? ??????? ?? Msado15.tlh ??? ???:

   _ConnectionPtr p;
   bstrConnect
   HRESULT           hr = S_OK;
   _ConnectionPtr    pConn;

   hr = pConn.CreateInstance( __uuidof( Connection ) );

      if( !FAILED( hr ) )
         hr = pConn->Open( L"pubs", L"sa", L"" );
				


??? pubs (????????) ???? ?????? ODBC.

#import ? Release() ????? ???? ????

???? #import ?? ??? ????? ????? AddRef ? QueryInterface ??????? ?? ????????. ??? ???? ??? ??? ???? ?? ??? ????? ??????? Release() ???? ???? ????? ????? ????? ?????.

??? _com_ptr_t ?? m_pInterface ????? ? ???. ??? #import ????? ???? ?????? ???? ?? ???? ??? ?? m_pInterface ???? ?????? ?????? ????? ????? decrementing ??? ???? ?????? ????? ?? ??? ????? ?????? ??????. ?? ???? ??????? ??????? ???? ???? ()--??? ??????? ???? ???? ???? AddRef() ??????? ?????--#import gladly ?????? ??? ???? ??? ?????, ????? ??????? ?????? ???????? ????? ????.

????? ???? ???? AddRef() ??? ??? (?? ????? ?? ????? ???) ? ?? ??? ??? ???.

?????

  • Com ???????? ?????? Rogerson ????? ISBN 1-57231-349-8
  • OLE COM "???? ??????" (Oleview.exe) ???? ???? ?? Visual C++ ?? ??? ??????? ?????.
  • ??????? ??????? Visual C++: ????? ??? #import
?????? ??? ??????? ??????? ???? ??? ???? ????????? ????????? ??????? ?? "????? ??????? ?? Microsoft:
182389FILE: Adovcbm.exe ADO 1.5 #import ? Getrows/???????? ????????
184968???? Adovcsp.exe ?????: ??????? ????? ??????? ???????? ADO
186387?????: Ado2atl.exe ????? ?????? ADO ?? COM
181733FILE: CancelBatch ? #import Adovcbtd.exe UpdateBatch ???????
166112PRB: ????? ?? EOF ??? ??????? #import ?? ADO
168354INFO: OLE ??????? ???????? ???? OLEDB ??? ??? ADO

???????

???? ???????: 169496 - ????? ??? ??????: 21/????/1426 - ??????: 3.2
????? ???
  • Microsoft ActiveX Data Objects 1.0, ????? ?????? ??:
    • Microsoft Visual C++ 4.2 Enterprise Edition
    • Microsoft Visual C++ 5.0 Enterprise Edition
    • Microsoft Visual C++ 6.0 Enterprise Edition
    • Microsoft Visual C++ 4.2 Professional Edition
    • Microsoft Visual C++ 5.0 Professional Edition
    • Microsoft Visual C++ 6.0 Professional Edition
    • Microsoft Visual C++, 32-bit Learning Edition 6.0
  • Microsoft ActiveX Data Objects 1.5, ????? ?????? ??:
    • Microsoft Visual C++ 4.2 Enterprise Edition
    • Microsoft Visual C++ 5.0 Enterprise Edition
    • Microsoft Visual C++ 6.0 Enterprise Edition
    • Microsoft Visual C++ 4.2 Professional Edition
    • Microsoft Visual C++ 5.0 Professional Edition
    • Microsoft Visual C++ 6.0 Professional Edition
    • Microsoft Visual C++, 32-bit Learning Edition 6.0
  • Microsoft ActiveX Data Objects 2.0, ????? ?????? ??:
    • Microsoft Visual C++ 4.2 Enterprise Edition
    • Microsoft Visual C++ 5.0 Enterprise Edition
    • Microsoft Visual C++ 6.0 Enterprise Edition
    • Microsoft Visual C++ 4.2 Professional Edition
    • Microsoft Visual C++ 5.0 Professional Edition
    • Microsoft Visual C++ 6.0 Professional Edition
    • Microsoft Visual C++, 32-bit Learning Edition 6.0
  • Microsoft ActiveX Data Objects 2.1, ????? ?????? ??:
    • Microsoft Visual C++ 4.2 Enterprise Edition
    • Microsoft Visual C++ 5.0 Enterprise Edition
    • Microsoft Visual C++ 6.0 Enterprise Edition
    • Microsoft Visual C++ 4.2 Professional Edition
    • Microsoft Visual C++ 5.0 Professional Edition
    • Microsoft Visual C++ 6.0 Professional Edition
    • Microsoft Visual C++, 32-bit Learning Edition 6.0
  • Microsoft ActiveX Data Objects 2.5, ????? ?????? ??:
    • Microsoft Visual C++ 4.2 Enterprise Edition
    • Microsoft Visual C++ 5.0 Enterprise Edition
    • Microsoft Visual C++ 6.0 Enterprise Edition
    • Microsoft Visual C++ 4.2 Professional Edition
    • Microsoft Visual C++ 5.0 Professional Edition
    • Microsoft Visual C++ 6.0 Professional Edition
    • Microsoft Visual C++, 32-bit Learning Edition 6.0
  • Microsoft ActiveX Data Objects 2.6, ????? ?????? ??:
    • Microsoft Visual C++ 4.2 Enterprise Edition
    • Microsoft Visual C++ 5.0 Enterprise Edition
    • Microsoft Visual C++ 6.0 Enterprise Edition
    • Microsoft Visual C++ 4.2 Professional Edition
    • Microsoft Visual C++ 5.0 Professional Edition
    • Microsoft Visual C++ 6.0 Professional Edition
    • Microsoft Visual C++, 32-bit Learning Edition 6.0
  • Microsoft Data Access Components 2.7
????? ??????: 
kbmt kbcode kbdatabase kbinfo kbusage KB169496 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????169496

????? ???????

 

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