20

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

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

7 Answers 7

15

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

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

For Jet 4.0 features it has to be ADO classic.

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 :)

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 is not without its strong points. For one, you will find more DAO code examples than ADO for Access/Jet.

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.

EDIT: 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 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 ;-)

11
  • "[For the record, the official name for what once was 'Jet' is now the 'Access database engine'.]" That is NOT TRUE. That is the name of the new database introduced in Access 2007. It does not change the name for all previous versions of Jet. And it's still JET, regardless of what they call it. Jun 25, 2009 at 1:04
  • 1
    No, the new engine introduced in Access 2007 is ACE. Access database engine is the collective term for Jet and ACE. I thought you were the one who likes to be precise...?
    – onedaywhen
    Jun 25, 2009 at 7:24
  • 1
    This mistake you make is assuming that when someone says 'Access' and they mean the database engine you erroneously correct them as 'Jet' without considering that they may be using ACE. The way MS have addressed this issue is to coin the term 'Access database engine' to be ambiguous yet precise.
    – onedaywhen
    Jun 25, 2009 at 7:46
  • 1
    "For Jet 4.0 features it has to be ADO classic." I disagree with singling out Jet 4.0 here. To me it's still a case of DAO vs ADO and no real reason to choose ADO when using Access as the FE and Access database as the backend. DAO has a lot more functionality in many areas.
    – Tony Toews
    Jun 25, 2009 at 21:32
  • Jet 4.0 has features that DAO cannot reach. No harm in using both, no?
    – onedaywhen
    Jun 25, 2009 at 23:29
8

DAO is the is the recommended technology here. ADO has much been depreciated, and is now being replaced with ADO.net.

Not only is DAO the native and recommended data object model for using MS access, it continues to be enhanced and now has a whole bunch of new features for sharepoint. In access 2007 we now have Support for SharePoint lists. This means that new DAO object model for 2007 allows a sharepoint list to be used and viewed as a SQL server table. That means you can use SQL on sharepoint lists (in fac there not even a oleDB provider that allows you to use SharePoint lists this way, but with DAO you can now do this). There is nothing of this sort that been added to ADO. So SharePoint lists from a access (dao) point of view sees these SharePoint lists as a standard table.

Furthermore DAO in access also has support for what we call complex data types. This was done to support XML lists from sharepoint. Keep in mind for the next version of access (2010) we are going to see a whole bunch more new additional features being added to DAO (JET is now called ACE).

So it is without question that DAO is the correct and good model to use. ADO is not receiving any more enhancements, and has been superseded by ADO.NET.

So the future belongs to DAO, and it’s clear that’s where Microsoft is investing its money in terms of MS access and terms of upgrading Access to work with things sharepoint.

Access 2007 received multi-value capabilities for its field definitions, and again this was a result of enhancements for supporting sharepoint. However, these features are part of JET and these enhancements can be used without sharepoint. they are now part of DAO.


edit: Perhaps I’m going to expand on this a little bit, and try to clarify what we have such opposing answers here, I can assure you that when using access 2007, you’re far better off to use DAO.

Where the confusion stems from, is if you look of the tools references when you choose to use the default data object model access 2007, the problem here is it’s not called DAO anymore. It is now called ACE.

When you use DAO in access 2007 You’ll note in the tool references, the reference is not set to DAO 3.6 ( that version has been depreciated, and also is now not part of MDAC download anymore). You’ll notice that the new reference when using DAO in ms-access is called:

Microsoft office 12.0 access database engine Object Library

Now the above is a bit of a mouth full, but the above is the correct for reference access 2007 when you’re going to use DAO in place of ADO.

In other words, perhaps we should call this DAO II.

In other words, this data engine continues to be enhanced, and will most assuredly see a 64 bit version of this engine for office 2010 (office 14).

So the question or confusion centers around what term were going to use when we refer to using DAO in access 2007. The confusion here is in fact that the documentation and even the tools ->reference does not call it DAO.

At the end of the day in access 2007, if you plan to use DAO then that means that you set the above reference, and do not set a reference to DAO 3.6. Regardless, it makes absolutely no sense to start using ADO now when it’s been depreciated, and the new DAO object model for access continues to be enhanced and invested in by Microsoft.

I hope this helps in clearing up the confusing here. While DAO/JET It’s being depreciated, the new version access 2007 is based on the same code base, except it continues to get enhanced. So the new data engine in access can be considered and called the new DAO object model.

I’m currently under NDA on this issue, but I can most surely tell you that for the next version of office (2010) we are going to see a whole slew of enhancements again.

So it is near unanimous among Access developers that when developing access applications and using the native data engine, the preference here is to use the DAO object model ( but keep in mind we’re not calling it that anymore, we called it ACE).

18
  • 1
    "[ADO classic] is now being replaced with ADO.net... has been superseded by ADO.NET" -- let's not go off topic. How is it possible to use ADO.NET in Access2007?
    – onedaywhen
    Jun 24, 2009 at 22:37
  • 1
    I keep telling you this but you don't seem to get it: Access developers as a rule don't give a rat's about DDL -- they don't use it, they don't need it. The fact that ADO supports some Jet DDL that DAO does not is an artifact of MS's internal power struggles and has zero effect on Access developers. Jun 25, 2009 at 1:11
  • 1
    "I just don’t understand what your final goal here is?" -- you were around in the Jet 4.0 era, right? Do you remember all those Access users begging for SharePoint integration? Recall those user group where customers were banging on the table demanding multi-value types? No, me neither. My point: the features ACE delivered weren't those on users wish lists. I don't believe I'm the only one who was underwhelmed by ACE engine-level features.
    – onedaywhen
    Jun 26, 2009 at 0:13
  • 1
    "the REAL issue here is the use of XML" -- then why no XML data type and XQuery for ACE, a la SQL Server 2005? Actually, don't answer that. While it's true I'm having fun, we've gone far from the question here. I suggest you ask your own question on SO about ACE and users' expectations. I'm sure I'd be happy to contribute an answer.
    – onedaywhen
    Jun 26, 2009 at 0:20
  • 2
    When the Access team takes the time to implement all the Jet 4.0 functionality into ACEDAO the ADO will have been superseded for the Access data engine (does ACEDAO support row level locking yet?) When the Access team takes the time to implement all the ADO objects' functionality (disconnected asynchronous-fetching hierarchical recordsets and all that Jazz) then ADO will have been superseded by ACEDAO. When the (??) team makes ADO.NET work in VBA then ADO.NET will have superseded ADO. Until then ADO is still needed full to provide full functionality in the Access world.
    – onedaywhen
    Jul 2, 2009 at 12:22
3

The answer to the question depends on what you're doing. If you're using Access to work with data that's in a format whose ADO interface is more versatile, then use ADO. If you're using Jet data, or using the Jet database engine to work with another database engine (via ODBC), then DAO is the right choice.

But that answer assumes you're working from Access. If you're working from some other programming environment, the answers will likely be completely different.

2

It depends on your needs. Neither tool is expected to disappear soon.

If you don't have experience in either ADO or DAO, you'll find DAO is much, much easier. So unless you need ADO, use DAO.

You added this critical item: "I'm trying to pull in data from an external source into an Access DB." This connectivity may require ADO.

3
  • I'm pulling in from Microsoft Excel, if that has any impact. Jun 24, 2009 at 17:23
  • Then I'd use DAO. My experience in ADO was forced solely by the need to link with non-Microsoft databases.
    – Smandoli
    Jun 24, 2009 at 21:07
  • Clarification: I meant to say by the need to link with non-Microsoft programs, specifically MySQL. For anything in MS Office, DAO is primed to produce.
    – Smandoli
    Jun 25, 2009 at 4:27
2

ADO is the current recommended access method. I think DAO has been deprecated for quite a number of years.

Looks like its been since Access 2000 - according to this link,

List of obsolete data access technologies - http://msdn.microsoft.com/en-us/library/ms810810.aspx#mdac technologies road map old_topic9

Quote from the above article, which was revised Dec 2008 - "Data Access Objects (DAO): DAO provides access to JET (Access) databases. This API can be used from Microsoft Visual Basic, Microsoft Visual C++, and scripting languages. It was included with Microsoft Office 2000 and Office XP. DAO 3.6 is the final version of this technology. It will not be available on the 64-bit Windows operating system."

15
  • 1
    KB 225962 only applies to Access 2000 and Access 2002. In Acess 2003 the default was DAO and no ADO. Thus that KB article is rather obsolete.
    – Tony Toews
    Jun 24, 2009 at 23:46
  • 1
    The article "List of obsolete data access technologies" was not written with Access in mind. And should be disregarded in an pure Access environment, that is where Access is both the application part and the data store part.
    – Tony Toews
    Jun 25, 2009 at 21:34
  • 1
    I don't think folk should read too much into which references are checked by default. You are free to set references to ADO and DAO, it only takes a few seconds ;-)
    – onedaywhen
    Jun 26, 2009 at 0:27
  • 1
    The out-of-the-box defaults do matter in Access. When MS was pushing ADO, they defaulted to ADO and left out DAO. This was wrong for most Access apps, which use only Jet data. They realized they'd made a mistake and a couple versions later, they defaulted back to DAO, as they should have all along. It does matter, partly because there are overlaps between the object models (two incompatible recordset objects, for instance). The ADO default was hostile to the true nature of Access and had nothing to do with the interests of Access developers. That attitude has changed, thankfully. Jun 26, 2009 at 20:15
  • 1
    @David W. Fenton: "It does matter, partly because there are overlaps between the object models" -- those overlaps are easy to deal with. Google around and look at some actual code. DAO code largely omits the 'DAO.' library qualifier and ADO code almost exclusively uses ADODB or ADOR qualifiers, which resolves the problem. You'd have to be particularly clueless not to get ADO and DAO code working in the same project... and you are not that clueless, so you are letting past politics affect your better judgment, methinks.
    – onedaywhen
    Jun 27, 2009 at 13:29
1

DAO just rocks in terms of performance compared to ADO. There's no comparison.

2
  • 3
    "DAO... compared to ADO. There's no comparison." -- make up your mind, LOL!
    – onedaywhen
    Jan 17, 2011 at 19:59
  • Yeah, I should have read that a bit closer before posting. But nonetheless, DAO is far faster than ADO.
    – Brandon
    Jan 18, 2011 at 13:30
0

Apologies that this is an answer, when it should have been a comment (I do not have the rep), but I wanted to clear up an erroneous claim that DAO/ACEDAO does not support Jet 4.0 record-locking. It does, and that is the default behaviour, irrespective of what certain MS articles claim.

The problem is this may introduce huge bloat (hugely fragmented DB file) when using DAO edit/update and you cannot turn it off in DAO/ACEDAO.

If you do have this issue, you can turn it off via first opening the database via an OLEDB connection using the correct Jet OLEDB:Database Locking Mode settings, which will allow you to set the database to page-level locking. This property will then be respected by consequent connections, DAO or otherwise, so you can then use DAO for fast updates etc.

This will then allow DAO to revert to the usual 8X performance compared to executing SQL statements.

Here are a couple of links pointing to the issue:

Does ACEDAO support row level locking?

http://www.access-programmers.co.uk/forums/showthread.php?t=47040

MS KB article, including code of setting locking mode with ADO, then using DAO on that DB - http://support.microsoft.com/?id=306435

1
  • I have not see anyone post code anywhere that shows how to open a DAO recordset and specify record vs. page locking. I don't believe it's possible, as there are no options defined to allow one to specify that. If you can find such code, please post it. Jan 18, 2011 at 0:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.