|
Daycounter,
Inc. Engineering Services |
||||||||
|
> Lab Book |
Home | Company | Services | Products | Partners | Clients | Site Map | Contact Us | |
|
|
Ado and Com Stuff Here are some lessoned learned by trying to figure out how to use Ado, another one of Microsoft's poorly implemented and cryptic interfaces. The data access SDK can be found at msdn.microsoft.com, and is called: mdacsdk.exe.
The two import libraries are should be included as follows: #pragma warning(push) The pragmas get rid of an anoying warning. For some unknown reason, they separated the ADO interface into 2 different DLLs: ADOX is for creating schema. ADO is for regular queries. On top of it you would have though Microsoft would have named the libraries such that you don't get namespace collisions between these to libraries since they are so closely tied. Since they didn't you have to rename their namespaces as shown above. The named_guids parameter of #import displays the GUIDs of the various classes so that you can access the interfaces without smart pointers.
Three ways to initialize a connection: 1. If you don't use smart pointers, without using the import directives, use the following headers from the SDK: #include <INITGUID.H> This is how you would initialize a connection object: hr= CoCreateInstance(CLSID_CADOConnection, NULL, CLSCTX_INPROC_SERVER, IID_IADOConnection, (void**)&m_MyConnection);
2. If you don't use smart pointers, yet want to use the import directives, you don't need the above headers just the proper #import: hr= CoCreateInstance(__uuidof(ADOX::Connection), NULL , CLSCTX_INPROC_SERVER, __uuidof(ADOX::_Connection), (void**)&m_MyConnection);
3. If you use smart pointers, use the the import files: m_spMyConnection->CreateInstance( __uuidof(ADO::Connection) ); The __uuidof is another Microsoft abomination to the C++ language. It retrieves the GUID which has been previously associated to a structure with the uuid() keyword.
Daycounter specializes in contract electronics design. Do you need some help on your project? Contact us to get a quote.
[Employment] [Downloads][Articles] [Contact Us] Call us now at 1.801.938.4264 - 502W. 9460S. Sandy, UT 84070 © Copyright 2004 Daycounter, Inc. All rights Reserved. |