Tutorial :Using ADO or OLEDB with ATL


I am writing an class using C++ (ATL).. I need to connect to a database. I am familiar with ADO but I see that all the functions are using IDispatch (late-binding/Automation). I am considering using OLEDB instead. What are the pros and cons of each? OLEDB seems like a lot of maintenance if the sql changes (tables, stored procs, etc). I did use the wizard to create some OLEDB headers and they dont seem as easy to "use" as ADO but speed does count. ADO also has an easy mechanism to convert the result to XML as well which is something I need. has any one used both before? which did you prefer? thanks!

to clarify, i am mentioning ATL only because there are ATL wizards for creating OLEDB consumer objects helps.


Using the ATL classes that wrap OLEDB is the way to go. If you consider that you're going to have to map your database schema to internal C++ classes regardless, then you're going to either do it with ADO and lots of painful IDispatch or with OLEDB which is a more natural in C++. If your database schema changes, you're going to have to modify your code regardless of the approach.

ADO is an OLE Automation wrapping of OLEDB, so the will not be any performance gains except that you'll have a lot less IDispatch thunking code to write.

There are many choices and approaches to getting that data into an XML form.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »