将 ADO 或 OLEDB 与 ATL 结合使用

发布于 2024-08-12 06:29:32 字数 304 浏览 2 评论 0原文

我正在使用 C++ (ATL) 编写一个类..我需要连接到数据库。我熟悉 ADO,但我看到所有函数都使用 IDispatch(后期绑定/自动化)。我正在考虑使用 OLEDB 代替。各自的优点和缺点是什么?如果 SQL 发生变化(表、存储过程等),OLEDB 似乎需要大量维护。我确实使用向导创建了一些 OLEDB 标头,它们似乎不像 ADO 那样容易“使用”,但速度确实很重要。 ADO 还有一个简单的机制可以将结果转换为 XML,这也是我所需要的。有人以前用过两者吗?你更喜欢哪个?谢谢!

澄清一下,我提到 ATL 只是因为 ATL 向导可以帮助创建 OLEDB 消费者对象。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

别挽留 2024-08-19 06:29:32

使用包装 OLEDB 的 ATL 类是正确的方法。如果您认为无论如何都必须将数据库模式映射到内部 C++ 类,那么您要么使用 ADO 和大量痛苦的 IDispatch 来完成此操作,要么使用 OLEDB(在 C++ 中更自然)。如果您的数据库架构发生变化,无论采用哪种方法,您都必须修改代码。

ADO 是 OLEDB 的 OLE 自动化包装,因此不会有任何性能提升,只是需要编写的 IDispatch thunking 代码会少很多。

有许多选择和方法可以将该数据转换为 XML 形式。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文