从过时的DAO类迁移 [英] Migrating from obsolete DAO classes

查看:84
本文介绍了从过时的DAO类迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在VS 2002/3中开发的C ++系统,该系统正在升级到当前技术,并且它广泛使用了CDAO类(CDAODatabase等).从VS 2005开始不推荐使用这些功能,并且在x64编译的代码中不可用.

I've got a C++ system developed in VS 2002/3 that I'm upgrading to current tech and it makes extensive use of CDAO classes (CDAODatabase, etc.). These are deprecated as of VS 2005 and unavailable in x64-compiled code.

我不知道这次升级应该迁移到哪些数据访问类.有什么建议么?是否可以通过最少的代码更新插入一组特定的类并获得相同的功能?

I can't figure out what data access classes i should be migrating to for this upgrade. Any suggestions? Is there a particular set of classes that I can just drop in and get the same functionality with minimal code updates?

推荐答案

您的选项将是ODBC,OLE DB&阿多它们都提供对多个数据库的访问(使用各自的提供程序),而DAO基本上是针对Microsoft Access的(尽管我认为支持ODBC桥).

Your options would be ODBC, OLE DB & ADO All of them offer access to multiple databases (using the respective provider), while DAO is basically for Microsoft Access (although I think supports an ODBC bridge).

ODBC是最旧的,但也是MFC向导中具有更好支持的(尽管也是最差的性能).您可以使用ODBC的原始C API或MFC包装器类(如CDatabase等)(连接到ODBC的MFC应用程序向导也使用这些MFC类).MFC类遵循与DAO(CDaoDatabase等)相似的对象模型.

ODBC is the most legacy but also the one with better support in the MFC Wizards (although also the worst performance). You can use the raw C API of ODBC or the MFC wrapper classes like CDatabase, etc (those MFC classes are also used by the MFC App Wizard that connects to ODBC). The MFC classes follow a similar object model than the ones for DAO (CDaoDatabase, etc).

OLE DB具有最佳性能,但是级别很低(尽管MFC向导中也支持它).您可以从原始C COM API或MFC App Wizard生成的智能指针包装器中使用它.

OLE DB has best performance but is very low level (although there is also support for it in the MFC wizards). You can use it from the raw C COM API or with the smart pointers wrappers that the MFC App Wizard generates

最后,ADO位于OLE DB之上(因此,与OLE DB兼容的提供程序也可以与ADO一起使用).性能不如OLE DB,但友好得多.ADO通常是ASP(.NET之前),VB6等中的首选技术.您可以通过三种方式使用ADO:

Finally ADO, sits on top of OLE DB (so a provider that is OLE DB compatible is also usable with ADO). Not as good performance as OLE DB, but much more friendly. ADO was often the technology of choice in ASP (pre .NET), VB6, etc. You can use ADO in three ways:

  • 使用原始C COM API(低级别,不建议使用).

  • Using the raw C COM API (low level, not recommended).

使用MFC类向导(或等效的最新版本)在COM接口周围生成MFC包装器类.

Using the MFC Class wizard (or equivalent in latest versions) that generates MFC wrapper classes around the COM interfaces.

使用#import指令,该指令生成智能指针包装器(并使用一些易于使用的类型,例如bstr_t,variant_t等)和C ++异常包装器来处理ADO错误.

Using the #import directive, that generates smart pointer wrappers (and uses several types that ease use like bstr_t, variant_t, etc) and C++ exception wrappers for the ADO errors.

我更喜欢使用ADO的#import方法,有关示例,请参见

I prefer the #import method with ADO, for samples, see

http://msdn.microsoft.com/en-us/library/windows/desktop/ms677563(v = vs.85).aspx

http://msdn.microsoft.com/en-us/library/windows/desktop/ms677493(v = vs.85).aspx

这篇关于从过时的DAO类迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆