Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it better to use ADO or DAO in Access 2007?

Tags:

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.

like image 993
Andrew Scagnelli Avatar asked Jun 24 '09 15:06

Andrew Scagnelli


People also ask

Should I use ADO or DAO?

Local databases and smaller projects should use DAO, while larger ones should use ADO. The reason for this is because developers generally want to keep things as simple as possible. ADO is very efficient with outside (remote) connections, while DAO is good for manipulating local objects.

Is DAO outdated?

Microsoft originally deprecated DAO in favor of ADO, but recently renamed DAO to Microsoft Access Engine (ACE) and is now pushing it as the preferred data access technology for Automation-supported environments (VBA, WSH etc.)

Is ADO deprecated?

Although not deprecated, ADO a mature OLE DB technology that hasn't been enhanced since ADO 6.0 was released with WDAC in Windows Vista over 10 years ago.

What is DAO in MS Access?

Microsoft Data Access Object, or DAO, is a library that ships with Microsoft Access. It allows you to create, maintain, and manage databases. It also provides various means of performing the necessary operations on a database. Microsoft DAO is a library published by Microsoft.


1 Answers

[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 ;-)

like image 51
onedaywhen Avatar answered Oct 29 '22 18:10

onedaywhen