在Access 2007中使用ADO还是DAO更好? [英] Is it better to use ADO or DAO in Access 2007?

查看:180
本文介绍了在Access 2007中使用ADO还是DAO更好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Access 2007中创建新数据库时,应使用ADO(ActiveX数据对象)还是DAO(数据访问对象)?

When creating a new database in Access 2007, should ADO (ActiveX Data Objects) or DAO (Data Access Objects) be used?

该数据库的一部分将从Excel 2007电子表格中导入数据.

Part of this database will be importing data from Excel 2007 spreadsheets.

推荐答案

[根据记录,曾经是'Jet'的正式名称现在是'Access数据库引擎'.]

[For the record, the official name for what once was 'Jet' is now the 'Access database engine'.]

对于ACE(Access2007引擎.accdb格式)功能,必须使用ACEDAO.

For ACE (the Access2007 engine .accdb format) features it has to be ACEDAO.

对于Jet 4.0功能,它必须是ADO经典版本.

For Jet 4.0 features it has to be ADO classic.

对于Jet 3.51和更早版本的功能,请选择ADO或DAO.两者都有优点和缺点.绝大多数Access数据库引擎功能是两者共有的.相互排斥的功能是有争议的.也许是一种生活方式的选择,但没什么大不了的.智能编码器充分利用了两者的优势:)

For Jet 3.51 features and earlier, pick either ADO or DAO. There are advantages and disadvantages to both. The vast majority of Access database engine functionality is common to both; the mutually exclusive functionality is arguable fringe. A lifestyle choice, perhaps, but no big deal. The smart coder uses the best of both :)

我已经使用了很多时间,ADO是我个人的喜好.它比DAO更现代,因此从结构上来说是一个改进:对象模型更平坦,DAO不会出现拆解问题,等等.更多的属性和方法并引入事件(DAO没有).用于异步连接和获取记录. ADO记录集可以断开连接,分层和伪造,而DAO记录集则不能.基本上,他们利用了DAO的优点,并使它们变得更好.

I've used both quite a bit and ADO is my personal preference. It is more modern than DAO, so architecturally it is an improvement: flatter object model, none of the tear down problems of DAO, etc. More properties and methods and introduces events (DAO has none) e.g. for asynchronous connection and fetching of records. ADO recordsets can be disconnected, hierarchical and fabricated, DAO recordsets cannot. Basically, they took the good things about DAO and made them better.

DAO并非没有优点.一方面,您将找到比ADO for Access/Jet更丰富的DAO代码示例.

DAO is not without its strong points. For one, you will find more DAO code examples than ADO for Access/Jet.

P.S.由于某些原因,喜欢DAO的人真的不喜欢ADO.忽略宣传. ADO不被弃用. ACE具有OLE DB提供程序,并且当前是使用64位ACE的唯一方法. ADO.NET并没有取代ADO经典,而VB.NET却已经取代了Access项目中的VBA6.

P.S. for some reason, folk who like DAO really dislike ADO. Ignore the propaganda. ADO isn't deprecated. The ACE has an OLE DB provider and is currently the only way of using ACE in 64 bit. ADO.NET hasn't replaced ADO classic any more than VB.NET has replaced VBA6 in Access projects.

只是为了澄清一下,对于Jet 4.0功能,它必须是ADO经典的",这是因为DAO 3.6仅对Jet 4.0的新功能进行了一些增强.例如,对于DECIMAL数据类型,您不能指定比例/精度. DAO完全缺少其他功能.例如,您可以在Jet 4.0中使用DAO(或ACE中的ACEDAO)执行以下操作吗?

just to clarify, "For Jet 4.0 features it has to be ADO classic," this is because DAO 3.6 only received a few enhancements for the features new to Jet 4.0. For example, for the DECIMAL data type you cannot specify scale/precision. Other features are missing completely from DAO. For example, can you do the following in Jet 4.0 using DAO (or ACEDAO in ACE for that matter)?

CREATE TABLE Test (
   col1 CHAR(4) WITH COMPRESSION DEFAULT '0000' NOT NULL, 
   CHECK (NOT EXISTS (
                      SELECT T1.col1 
                        FROM Test AS T1 
                        WHERE T1.col1 <> '0000' 
                        GROUP 
                           BY T1.col1 
                       HAVING COUNT(*) > 1
                      ))
);

(提示:具有表级数据完整性约束的可压缩固定宽度文本列.)否,您不能.

(hint: compressible fixed-width text column with table-level data integrity constraint.) No, you cannot.

AFAIK对ACEDAO的唯一增强是对新的ACE功能的改进,即它们并没有弥补DAO中Jet 4.0的不足.他们为什么要这么做?我们仍然有ADO可以填补空白.最好让团队更有效率地花费时间,例如修复令人讨厌的DECIMAL排序错误,对我而言,ACE最好的东西;-)

AFAIK the only enhancements to ACEDAO was for the new ACE functionality i.e. they didn't go back and fill in the Jet 4.0 gaps in DAO. And why should they? We still have ADO to plug the gaps. Better that the team spent their time more productively, like fixing that annoying DECIMAL sort bug, for me the best thing about ACE ;-)

这篇关于在Access 2007中使用ADO还是DAO更好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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