开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜