ADO vs. DAO

J

Jack Hudson

For years now MS has suggested using ADO as DAO is obsolete. However, I
still see MVP's giving code solutions using DAO. Not being critical here,
simply curious to know why ADO solutions are not given more frequently. Any
observations y'all like share?

Regards, Jack Hudson
 
R

Rick Brandt

Jack said:
For years now MS has suggested using ADO as DAO is obsolete. However, I still
see MVP's giving code solutions using DAO. Not
being critical here, simply curious to know why ADO solutions are not
given more frequently. Any observations y'all like share?

Regards, Jack Hudson

DAO was never obsolete just not the shiny new thing on the shelf. The
overwhelming consensus that I see in these groups is that ADO offers no
advantage when working against Jet data and has some disadvantages. Since most
posters in these groups are working against Jet data it makes sense to continue
posting DAO solutions.

I for one almost never use Jet tables but still use DAO because it works for
everything I need and have never felt any reason to learn something new.
 
T

Tony Toews [MVP]

Jack Hudson said:
For years now MS has suggested using ADO as DAO is obsolete. However, I
still see MVP's giving code solutions using DAO. Not being critical here,
simply curious to know why ADO solutions are not given more frequently. Any
observations y'all like share?

We're old farts?

What Rick said is generally true. I'm more comfortable in DAO as
that's what I've been using for a long time. And ADO requires two
lines of code not one.

The only thing about ADO that is useful to me is that it will allow
you to reset the autonumber seed with DAO won't. And that is pretty
minor and seldom used.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
 
A

Albert D. Kallal

Jack Hudson said:
For years now MS has suggested using ADO as DAO is obsolete. However, I
still see MVP's giving code solutions using DAO. Not being critical here,
simply curious to know why ADO solutions are not given more frequently.
Any observations y'all like share?

Regards, Jack Hudson

ADO was a newer object model, and is not really tied to JET.

In some ways, the ADO object model is a bit cleaner then DAO. (the two areas
that I notice the most is are when you do a update in ADO, the record
pointer does not move...in DAO it does, and that tends to be a bit of pain
(actually quite a bit of pain). Also, in ADO if you move to the next record,
you don't have to issue a update, were as in DAO you do. And, if memory
servides me correct, the "edit" method is optional in ADO. These about the
only two, or three real things as to why I think ADO is a bit cleaner then
DAO.

However, it is ADO that really be put out to pasture, and we are now being
told to use ado.net.

However, for ms-access, we continue to receive new versions of JET..and
access 2007 has new data types. So, in effect, DAO continues to get
enhancements and new features (if you consider DAO as part of the jet
engine). ADO it not receiving any such enhancements.


In access 2007, the JET odbc direct ability was removed. So, this means that
JET is still being changed, and this is one example of a feature that has
been put to pasture. This issue does favour using ADO in this case (as then
you can connect to sql server, and by-pass jet. However, jet + odbc via dao
still functions as usual, and pass-though queries will still by-pass jet,
and thus you get much the same result.

In addtion, workgroup secirty for access 2007 has been removed. So, in
effect, this is two areas which reduce the advantage of using DAO over that
of ADO.

However, in both cases, dao, or ado hitting sql server perform about the
same.

so, in a funny way, about 7 years ago, we were told to use ADO, but we all
just continued on using DAO. As time passed, lo, and behold...today, DAO is
still strong, and in the ms-access community DAO is stronger then is ADO,
and DAO still enjoys good support from Microsoft.

So, it likely more developers are dropping ADO and moving to ADO.NET then we
who continue to use DAO.

If your developing the application in mind with eventual moving to sql
server, then there is some advantages to using ADO in your application. And,
we have a good number of vb6 developers who now jumped into ms-access, and
they are also more familiar with ADO. So, what is really nice is that both
dao, and ado enjoy widespread support in ms-access. For the most part those
being told to throw out, and stop using DAO were actually a bit
miss-informed.

It is not really much a problem or issue, DAO tends to be the choice when
building ms-access application (because that is the way we always done
it..and it tends to be a bit less code in a good number of cases -- sans my
two examples).

You certainly can use ADO also. ADO is another layer on top, and does
abstract out the database more then DAO. So, if you eventually plan to
change the database engine, ADO is still a better choice.
 
D

Douglas J. Steele

Jamie Collins said:
However, "overwhelming consensus that... ADO offers no advantage" must
be a MMM (misleading statement, misstatement or misunderstanding)
because there are some functionality accessible to ADO and not DAO;
willingness to accept Hobson's Choice is a huge advantage <g>. It may
be a popular misconception that ADO offers no advantage but 'popular'
does not equate with 'truth'!

While it's true that there's functionality available only in ADO, there's
also functionality available only in DAO.

See MichKa's article "What does DAO have that ADO/ADOx/JRO do not have (and
might never have!)" at http://www.trigeminal.com/usenet/usenet025.asp
 
D

Dirk Goldgar

In
Jamie Collins said:
Absolutely correct and thanks for pointing out my omission...


...but from a quick glance, not only is that article obviously biased,
it contains a number of MMMs (misleading statement, misstatement or
misunderstanding). How many problems must I highlight for you to
desist in linking to this article <g>?
[...]

Very interesting post, Jamie. However, most of your rebuttals involve
executing Jet SQL statements via ADO, contrasted with manipulating
programming objects via DAO. I'm not convinced this is a fair
comparison. Any process that lets you pass SQL statements to the
database engine will give you access to those features of the database
engine that are supported in that engine's dialect of SQL. That's
different, though, from an object library that provides classes,
methods, and properties to manipulate those features. Both DAO and ADO
can execute SQL statements to accomplish many of the tasks the article
refers to -- at least, reading your post I am now aware that they can --
but DAO provides Jet-specific programming objects to accomplish those
same ends. To a SQL-oriented person, that may be of no importance, but
to a code-oriented person it can be easier to create objects and
manipulate properties than to look up uncommon SQL syntax.
 
A

Albert D. Kallal

Jamie Collins said:
You seem to be using 'we' to mean 'developers across all MS platforms'
e.g. Visual Studio and Office. I think you comments about ado.net are
misleading in the context of ms-access because AFAIK there is no
practical way of using ADO.NET in an ms-access project whereas ADO
classic remains a viable option.

Sure, I 100% with the above. I was using "we" as a general term
for developers. I was kind of just pointing out that likely more
people are dropping ADO as compared to DAO right now because
that is the new upgrade path for the .net folks.
So, it is apples and oranges, but the message we kind of get
today is that ado.net is the next new thing...and message was
much the same for ado over dao. It not a real big issue because
Microsoft has strongly supports dao in ms-access.

Out of interest, are you recommending the use of the Access2007 multi-
value data types in a standard ms-access project (i.e. other than
sharepoint integration etc)? I've read your opinions on pick, which of
course has the required predicates, but I wondered where you stand on
the Access/Jet implementation of multi-value types. I don't see anyone
in these groups evangelizing or even advocating them. It is relevant
to this thread because you are using them to add to the case for DAO.

I of course am actually a big fan of the muiti-values. to me, many
applications after a number of years begin to start falling apart at the
seams. Fro example, a person has a customer record, and they need to store
their favourite foods. You see the "amateur" developer start adding fields
like food1, food2, food3, or perhaps just one field of food, and in side the
field they type in data like

Apple Pie, Steak, Cheesecake

In both cases, the data is terribly un-normalized. When you use multi-value
fields, your actually normalizing the data. What that means is that after 5
years of a person modifying the database, you don't have to throw it out,
and call in a bunch of high priced oracle experts. So, in a way, those
multi-value fields allow someone to build correctly formed database
structures, and they don't even know it. In fact, I think *any* field should
be able to go multi-value, and the option in the "other" tab that stats what
the enter key does should have a option "allow multi-values on enter key".
(the option now have enter key = new line, I want to see it go: enter key =
new multi value).

In other words, uses should be able to add multi-values to any field, and do
it without barely thinking. The industry falsehood has always been that
multi-value systems are not correctly relational, and not normalized. This
is not true at all. One of the great big secrets of multi-value systems (of
many of which been around for 20, or even 30+ years) is that the designs and
data of the applications where VERY easy to extend over time..so, they did
not being to fall apart at the seems like non normalized applications do
after many years of modifications. As a result, there is TON of old
multi-value systems that continue to run today, when most of the other
vendors from that period have long disappeared. Those old muiti-value
systems continue to run, because their data allowed the applications to be
flexible, and stay *more* normalized then the competing systems of that time
period.

So, I not yet really promoting multi-value fields, but I do believe in them
strongly because they make people actually normalize data without even a
clue to this fact.

In a2007 a person can setup a database with "favourite" foods, and in effect
without having to write one line of code, they actually built that many to
many relation with a junction table without even knowing they were supposed
to -- I think that a huge leap forward for these users.

Users can't think in terms of relational databases, but they sure know that
they want to save a list of favourite foods in their database, and a2007
lets them do that without even realizing they are doing it the right way.

Now, as a seasoned developer, I know how to build that favourite foods list,
so, the really big question becomes will I use this feature? Well, not
likely, not quite yet. However, for a lot of little pick lists, and things
like what category a contact belongs to, those auto-matic pick lists that
a2007 has can actually save developer time also. The problem for seasoned
developers is that the tables and relationships are not exposed in the
relationships windows (however, in dao..and in reocrdset code...they are!!).
This "exposed" part is much a sticking point for me.
Another thing to note is that DAO has still not got enhancements for
some of the Jet 4.0 features (e.g. creating CHECK constraints); ADO
(via the OLE DB providers) has received such enhancements.

Sure, there is a few things in ado that was nicely improved..and mostly done
for those folks coming from sql server. On the other hand..not many of us
use the constraints features. And, the create procedure is really nothing
more
then a select, or saved query anyway.

The popularity of DAO today simply shows that MS could not get rid of it,
and what really amazing is that MS is working hard to keep us happy on this
front. In other words, they simply looked at the market, and access
develops...and said, gee...dao is popular...so, we keep it alive and well.
The beauty is that ms-access gives you a great choice with dao, or ado. I am
thankful to MS for this extra effort and continued support of dao....but,
either one is a fine choice in access.
 
D

David W. Fenton

For years now MS has suggested using ADO as DAO is obsolete.
However, I still see MVP's giving code solutions using DAO. Not
being critical here, simply curious to know why ADO solutions are
not given more frequently. Any observations y'all like share?

MS has changed its mind. It is now recommending all DAO for Jet
data, as it should have been from the beginning.
 
D

David W. Fenton

That certainly true but MSFT did give the impression that DAO was
no longer MSFT's data access component of first choice e.g.

Intermediate Microsoft Jet SQL for Access 2000
http://msdn2.microsoft.com/en-us/library/aa140015(office.10).aspx

Using ADO vs. DAO
"In previous versions of Access, Data Access Objects (DAO) was the
primary data access method. That has now changed. Although DAO is
still supported, the new way to access data is with ADO."

Assuming that documentation was produced for the release of Office
2000, that information is EIGHT YEARS OLD.

Microsoft has changed its tune. That is obvious by the way they've
changed the default references in newly created databases.
There is an overwhelming preference for DAO, which is surely the
simple explanation as to why we see more DAO solutions posted i.e.
it is in proportion to greater code/knowledge base.

It's a perfectly logical preference when most of the discussion here
is about using Jet data. ADO *never* made any sense for Jet data,
and anyone who understands what a database abstraction layer is
should see that (ADO is a database abstraction layer; DAO is an
interface to a particular database engine that has hooks that allow
it to be used to access lots of other db engines).
Also note that we see
many MVP wannabes in these groups and MVPs prefer DAO, imitation
being the sincerest form of flattery; put another way: you may
prefer ADO yourself but exclusively posting ADO is not the path to
glory here.

Posting ADO code for Jet problems would certainly not be the "path
to glory" because it would show that you're not really competent to
be giving advice.
Take, for example, the oft requested task of seeding an
incrementing autonumber: there is no shame is posting the DAO
solution (create column with autonumber property, insert (seed -
1) rows, delete all rows) and the straightforward and elegant ADO
solution (create a column with the autonumber property seeded
appropriately) is rarely seen.

Microsoft made a decision (not on logic, but on marketing) to leave
certain new Jet 4 features out of DAO and put them in ADO, instead.
That is a flaw in MS's strategy, not in DAO.

Now that Jet is again a live development platform, I expect the
ACCDB version of DAO to gain lots of new features to keep up with
the development of the ACCDB Jet engine.
However, "overwhelming consensus that... ADO offers no advantage"
must be a MMM (misleading statement, misstatement or
misunderstanding) because there are some functionality accessible
to ADO and not DAO;

And there are things in DAO that ADO can't do (hence the need for
JRO).
willingness to accept Hobson's Choice is a huge advantage <g>. It
may be a popular misconception that ADO offers no advantage but
'popular' does not equate with 'truth'!

ADO is slower than DAO for Jet data. It lacks features that require
you to use *two* external libraries instead of one. It's not native
to the db engine.

It makes *no* sense whatsoever to use ADO for Jet except for the
small handfull of features that Microsoft chose to put in ADO and
not in DAO 3.6. A short list (not complete):

1. UserRoster
2. Byte field and Decimal field alteration
3. Autonumber seed manipulation
I don't think many people would recommend DAO for non-Jet tables.

It depends on the context. DAO is very good with external data
sources because *Jet* is very good.
From
personal experience DAO+Oracle was disastrous and mapping data
types between DAO and SQL Server couldn't be made to fit :(

In both cases an ADO driver for the specific db engine may be much
better (more full-featured and faster) than the corresponding ODBC
driver. For SQL Server, yes, ADO makes a lot of sense, sure. But for
other db engines, it's a choice that needs to be made based on how
well things work with the drivers provided for it.
 
D

David W. Fenton

Another thing to note is that DAO has still not got enhancements
for some of the Jet 4.0 features (e.g. creating CHECK
constraints); ADO (via the OLE DB providers) has received such
enhancements.

You're confusing the ACCDB version of DAO with the Jet 4 version of
DAO. The former is maintained by the Access group. The latter is
maintained by the Windows group (because Active Directory stores its
data in Jet 4 format). So far as I can figure, the Jet 4 version of
DAO is not being updated any longer, and my guess is that as soon as
Windows gets its database-based file system (formerly WinFS), that
Jet will be dropped from Windows and Jet 4 will be officially dead.
At that point the only version of Jet will be the ACCDB version
(though Access will still likely include the default Jet 4 support,
including support for Jet 4's DAO library).
 
D

David W. Fenton

The industry falsehood has always been that
multi-value systems are not correctly relational, and not
normalized.

My issue is that the ACCDB is storing the values behind the scenes
in properly normalized data structures and displaying it as a single
field, but you have no access to that data structure.

What happens when you start needing to have multiple attributes for
your values? With a multi-value field, you don't have access to the
structure. But with an explicit many-to-many structure, it's a piece
of cake to add your attributes to the join table.

That said, I can think of many cases where I could have used a
multi-value field. And, indeed, I have stored denormalized
multi-value data in a few applications (and provided a listbox
interface for changing the data stored in the fields), and the new
multi-value field would have made that a lot easier.
 
D

David W. Fenton

The popularity of DAO today simply shows that MS could not get rid
of it, and what really amazing is that MS is working hard to keep
us happy on this front.

It's not just a matter of popularity. It's a matter of logic. It's
much easier to develop a db-engine specific interface than it is to
develop an abstraction layer that works with multiple db engines.

ADO was a very worthy successor and replacement for ODBC. It added a
lot of things that ODBC had needed for a *very* long time (because
db engines had evolved well beyond the original design of ODBC). But
it couldn't possibly replace something like DAO, which was
specifically designed for Jet. And the reason DAO is so powerful is
that Jet is so powerful, with its ability to intelligently
communicate with all sorts of db engines other than itself. No, it's
not always perfectly efficient because it guesses wrong, but so does
ADO!
 
T

Tony Toews [MVP]

Jamie Collins said:
CurrentProject.Connection.Execute "ALTER TABLE YourTable ALTER
autonumber_col INTEGER IDENTITY(1, 1);"

That's _one_ line of code by my reckoning.

Ah, I wasn't very clear. The execute takes one line but the
openrecordset requires two lines.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
 
V

Vladimír Cvajniga

This is a copy of old web page (2000)
============================================================

Eleven Reasons Not to Migrate to ADO
by Helen Feddema

--------------------------------------------------------------------------------

a.. Maturity: DAO is a mature technology, with the bugs worked out. ADO,
on the other hand, is brand-new and still quite buggy. Many developers (and
ordinary users!) would prefer to wait out the v. 1.0 stage, and defer using
ADO in real-life applications until it is more stable.

b.. Your code library: If you have been doing Access development for a
while, you probably have a stock of DAO code segments you can pop into new
projects; switching to ADO will require learning new syntax and developing
code from scratch. Why abandon your investment of time and effort?

c.. Working with Access 97: If you are writing code (say VBS code on an
Outlook form) that may work with either Access 97 or Access 2000, DAO will
work, but ADO won't, since Access 97 doesn't support ADO. Outlook forms are
substantially the same in all versions of Outlook, and Outlook VBS code can
run in all versions of Outlook too, so long as recently introduced language
elements are avoided. Using DAO to communicate with Access from Outlook VBS
ensures that your code will run with either Access 97 or Access 2000.


------------------------------------------------------------------------------

Check out our Visual Basic Special!


------------------------------------------------------------------------------


d.. Form and report recordsets: Form and report recordsets in Access 2000
still use DAO exclusively, so you must use DAO to work with recordsets and
recordset clones. Since you must use DAO for these purposes (for example, to
synchronize a form with a record selected in a combo box in a form header),
it is a lot simpler to just use DAO for all your coding, to avoid confusion
between the two object models.

e.. Class prefixes: If you work with both the DAO and ADO object models,
you must prefix all objects that belong to both object models with the
appropriate class name or you may have an error in running your code. This
happens because of objects (like the Recordset object) which belong to both
object models, but which have different properties or methods in DAO and
ADO. If you stick to the DAO object model, you don't need to use class
prefixes; just make sure that DAO is checked in the References dialog and
ADO is not checked.

f.. ISAM and ODBC connectivity: DAO is designed specifically for the Jet
database engine, and thus incorporates ISAM and ODBC connectivity, making
back-end providers look as much like native Jet as possible. This allows for
easier coding (no need for lots of special cases).

g.. Performance: DAO is much more efficient at using the Jet engine than
ADO--as much as 5 to 10 times faster. Faster performance is always welcome!
Additionally, all DAO objects you create use the same Jet session, while in
ADO every Connection object and ADO Data control uses a separate Jet
session, which can lead to Jet running out of resources. This is an
important consideration, at least if you need to use lots of objects in a
project.

h.. Distributing applications: When using DAO, only a small set of files
must be distributed to users' computers. When distributing ADO, all of ADO
and OLE DB (including ODBC) must be included in the setup files package. The
smaller the distribution package, the better, especially if you must use
floppy disks for the setup files.

i.. Wild Cards and Stored Queries: Because ADO uses different query
wild-card characters than DAO, stored queries created in DAO won't work in
ADO (at least if they use wild cards). So, if you don't want to have to
replace all the wild cards used in queries with the new ADO wild cards,
stick to DAO.

j.. Security: DAO has a full Security model, but ADO has no way to specify
the PID. If the System.mdw file is deleted, you can't recreate security
accounts from scratch, and if you don't have a usable backup System.mdw, you
are stuck.

k.. If it ain't broke....: Sometimes it seems as though Microsoft changes
things just for the sake of change. Why else would the set of developer
tools that accompanies Access have a different name and acronym with every
release? This set of tools was called ADK for Access 1.1, ADT for Access
2.0, ODT for Access 95, ODE for Access 97, and now MOD for Access 2000. It's
not exactly the same, but DAO is a robust and highly functional object
model. So long as you are working with Access data sources, there is no need
to move to ADO yet.
 
V

Vladimír Cvajniga

This is a copy of old web page (2000)
Be benevolent to some obsolete ideas
============================================================

Eleven Reasons Not to Migrate to ADO
by Helen Feddema

--------------------------------------------------------------------------------

a.. Maturity: DAO is a mature technology, with the bugs worked out. ADO,
on the other hand, is brand-new and still quite buggy. Many developers (and
ordinary users!) would prefer to wait out the v. 1.0 stage, and defer using
ADO in real-life applications until it is more stable.

b.. Your code library: If you have been doing Access development for a
while, you probably have a stock of DAO code segments you can pop into new
projects; switching to ADO will require learning new syntax and developing
code from scratch. Why abandon your investment of time and effort?

c.. Working with Access 97: If you are writing code (say VBS code on an
Outlook form) that may work with either Access 97 or Access 2000, DAO will
work, but ADO won't, since Access 97 doesn't support ADO. Outlook forms are
substantially the same in all versions of Outlook, and Outlook VBS code can
run in all versions of Outlook too, so long as recently introduced language
elements are avoided. Using DAO to communicate with Access from Outlook VBS
ensures that your code will run with either Access 97 or Access 2000.


------------------------------------------------------------------------------

Check out our Visual Basic Special!


------------------------------------------------------------------------------


d.. Form and report recordsets: Form and report recordsets in Access 2000
still use DAO exclusively, so you must use DAO to work with recordsets and
recordset clones. Since you must use DAO for these purposes (for example, to
synchronize a form with a record selected in a combo box in a form header),
it is a lot simpler to just use DAO for all your coding, to avoid confusion
between the two object models.

e.. Class prefixes: If you work with both the DAO and ADO object models,
you must prefix all objects that belong to both object models with the
appropriate class name or you may have an error in running your code. This
happens because of objects (like the Recordset object) which belong to both
object models, but which have different properties or methods in DAO and
ADO. If you stick to the DAO object model, you don't need to use class
prefixes; just make sure that DAO is checked in the References dialog and
ADO is not checked.

f.. ISAM and ODBC connectivity: DAO is designed specifically for the Jet
database engine, and thus incorporates ISAM and ODBC connectivity, making
back-end providers look as much like native Jet as possible. This allows for
easier coding (no need for lots of special cases).

g.. Performance: DAO is much more efficient at using the Jet engine than
ADO--as much as 5 to 10 times faster. Faster performance is always welcome!
Additionally, all DAO objects you create use the same Jet session, while in
ADO every Connection object and ADO Data control uses a separate Jet
session, which can lead to Jet running out of resources. This is an
important consideration, at least if you need to use lots of objects in a
project.

h.. Distributing applications: When using DAO, only a small set of files
must be distributed to users' computers. When distributing ADO, all of ADO
and OLE DB (including ODBC) must be included in the setup files package. The
smaller the distribution package, the better, especially if you must use
floppy disks for the setup files.

i.. Wild Cards and Stored Queries: Because ADO uses different query
wild-card characters than DAO, stored queries created in DAO won't work in
ADO (at least if they use wild cards). So, if you don't want to have to
replace all the wild cards used in queries with the new ADO wild cards,
stick to DAO.

j.. Security: DAO has a full Security model, but ADO has no way to specify
the PID. If the System.mdw file is deleted, you can't recreate security
accounts from scratch, and if you don't have a usable backup System.mdw, you
are stuck.

k.. If it ain't broke....: Sometimes it seems as though Microsoft changes
things just for the sake of change. Why else would the set of developer
tools that accompanies Access have a different name and acronym with every
release? This set of tools was called ADK for Access 1.1, ADT for Access
2.0, ODT for Access 95, ODE for Access 97, and now MOD for Access 2000. It's
not exactly the same, but DAO is a robust and highly functional object
model. So long as you are working with Access data sources, there is no need
to move to ADO yet.
Return to: vb.oreilly.com
 
V

Vladimír Cvajniga

Oops, I wanted to post it only once... sry...

Vladimír Cvajniga said:
This is a copy of old web page (2000)
Be benevolent to some obsolete ideas
============================================================

Eleven Reasons Not to Migrate to ADO
by Helen Feddema

--------------------------------------------------------------------------------

a.. Maturity: DAO is a mature technology, with the bugs worked out. ADO,
on the other hand, is brand-new and still quite buggy. Many developers
(and ordinary users!) would prefer to wait out the v. 1.0 stage, and defer
using ADO in real-life applications until it is more stable.

b.. Your code library: If you have been doing Access development for a
while, you probably have a stock of DAO code segments you can pop into new
projects; switching to ADO will require learning new syntax and developing
code from scratch. Why abandon your investment of time and effort?

c.. Working with Access 97: If you are writing code (say VBS code on an
Outlook form) that may work with either Access 97 or Access 2000, DAO will
work, but ADO won't, since Access 97 doesn't support ADO. Outlook forms
are substantially the same in all versions of Outlook, and Outlook VBS
code can run in all versions of Outlook too, so long as recently
introduced language elements are avoided. Using DAO to communicate with
Access from Outlook VBS ensures that your code will run with either Access
97 or Access 2000.


------------------------------------------------------------------------------

Check out our Visual Basic Special!


------------------------------------------------------------------------------


d.. Form and report recordsets: Form and report recordsets in Access 2000
still use DAO exclusively, so you must use DAO to work with recordsets and
recordset clones. Since you must use DAO for these purposes (for example,
to synchronize a form with a record selected in a combo box in a form
header), it is a lot simpler to just use DAO for all your coding, to avoid
confusion between the two object models.

e.. Class prefixes: If you work with both the DAO and ADO object models,
you must prefix all objects that belong to both object models with the
appropriate class name or you may have an error in running your code. This
happens because of objects (like the Recordset object) which belong to
both object models, but which have different properties or methods in DAO
and ADO. If you stick to the DAO object model, you don't need to use class
prefixes; just make sure that DAO is checked in the References dialog and
ADO is not checked.

f.. ISAM and ODBC connectivity: DAO is designed specifically for the Jet
database engine, and thus incorporates ISAM and ODBC connectivity, making
back-end providers look as much like native Jet as possible. This allows
for easier coding (no need for lots of special cases).

g.. Performance: DAO is much more efficient at using the Jet engine than
ADO--as much as 5 to 10 times faster. Faster performance is always
welcome! Additionally, all DAO objects you create use the same Jet
session, while in ADO every Connection object and ADO Data control uses a
separate Jet session, which can lead to Jet running out of resources. This
is an important consideration, at least if you need to use lots of objects
in a project.

h.. Distributing applications: When using DAO, only a small set of files
must be distributed to users' computers. When distributing ADO, all of ADO
and OLE DB (including ODBC) must be included in the setup files package.
The smaller the distribution package, the better, especially if you must
use floppy disks for the setup files.

i.. Wild Cards and Stored Queries: Because ADO uses different query
wild-card characters than DAO, stored queries created in DAO won't work in
ADO (at least if they use wild cards). So, if you don't want to have to
replace all the wild cards used in queries with the new ADO wild cards,
stick to DAO.

j.. Security: DAO has a full Security model, but ADO has no way to
specify the PID. If the System.mdw file is deleted, you can't recreate
security accounts from scratch, and if you don't have a usable backup
System.mdw, you are stuck.

k.. If it ain't broke....: Sometimes it seems as though Microsoft changes
things just for the sake of change. Why else would the set of developer
tools that accompanies Access have a different name and acronym with every
release? This set of tools was called ADK for Access 1.1, ADT for Access
2.0, ODT for Access 95, ODE for Access 97, and now MOD for Access 2000.
It's not exactly the same, but DAO is a robust and highly functional
object model. So long as you are working with Access data sources, there
is no need to move to ADO yet.
Return to: vb.oreilly.com
 
R

RoyVidar

Tony Toews said:
Ah, I wasn't very clear. The execute takes one line but the
openrecordset requires two lines.

Tony

<grin>

From the help file - Execute Method (ADO Connection):

"For a row-returning command string:

Set recordset = connection.Execute(CommandText, RecordsAffected,
Options)

Return value
Returns a Recordset object reference."

defaults to forwardonly, readonly, though.

dim rs as adodb.recordset
dim s as string
s = "select * from mytable"

set rs = currentproject.connection.execute(s, , adcmdtext)

debug.print rs.getstring

For other cursor/locktype, I think, one would need to either rely upon
implicit instantiation (shudder), or use more than one line.

dim rs as new adodb.recordset
dim s as string
s = "select * from mytable"

rs.open s, currentproject.connection, adopenkeyset, adlockoptimistic,
adcmdtext

debug.print rs.getstring

(air code)
 
P

(PeteCresswell)

Per Jack Hudson:
Not being critical here,
simply curious to know why ADO solutions are not given more frequently. Any
observations y'all like share?

I've dabbled in ADO - especially when going against SQL Server or Oracle and
retrieving multiple recordsets in one server hit.

But my experience is that writing DAO takes a *lot* less code and once I read
that DAO works better for JET back ends (which most of my projects are), I
decided to stick with DAO unless I could come up with a reason to use ADO (as in
SQL Server-based apps).
 
M

MikeR

Jack said:
For years now MS has suggested using ADO as DAO is obsolete. However, I
still see MVP's giving code solutions using DAO. Not being critical here,
simply curious to know why ADO solutions are not given more frequently. Any
observations y'all like share?

Regards, Jack Hudson
In my experience, DAO is WAAAAAAY faster than ADO for Access dbs.
Mike
 
P

(PeteCresswell)

Per MikeR:
In my experience, DAO is WAAAAAAY faster than ADO for Access dbs.

If it is as it seems - an extra layer on top of DAO - it seems almost
inevitable.

(I'm guessing that the thingie that we supply to ADO that lets it read DAO
really just lets ADO translate it's requests into DAO-speak and relay them to
JET).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

DAO vs ADO 5
DAO IS DED 18
dao vs. ado 4
Should I Learn DAO, ADO or ADO.NET ? 2
DAO vs ADO 10
ADO vs DAO Access 2007 0
ADO vs DAO - worth converting ? 8
ADO vs DAO Recordsets 2

Top