views:

555

answers:

4

I've written a small (8-10 laptops) point-of-sale system running over a wireless network, as an HTA that reads from/writes to an Access MDB located on a network share.
I need to use ADO - GetString and the user roster are not available with DAO.
I also need to use DAO - the MDB cannot be compacted with ADO.

I know that:
1) If the database backend is not an Access MDB, I should use ADO.
2) If the backend is an MDB, but I want to upgrade to SQL Server at some point, I should use ADO.
3) Within an Access application, or any other VBA/VB application, I should use DAO, as ADO must go through a translation layer of the Jet OLE DB Provider, while DAO is more direct.
4) VBScript/JScript allows me to use either DAO or ADO.

The two-part question is as follows:
1) In this software environment (HTA/scripting), is it better to use ADO rather than DAO?
2) Does ADO offer any benefits because the HTA is reading/writing over a wireless network?

+1  A: 
  1. If the only reason you need DAO is to compact the database, you can use DAO for that, and use ADO for everything else. You are not limited to using only ADO or DAO.

  2. The biggest benefit of using ADO is that it will be easier to move to SQL Server Express when the time comes. You should do that sooner rather than later, as SQL Server Express offers all of the benefits of MSAccess databases without the drawbacks. SQL Server Express is free, and it will easily handle the system size you are proposing.

Access databases corrupt easily in a multi-user environment, especially when a wireless network is involved. If you are worried about losing the benefits of working in MSAccess, you can still attach to SQL Server using linked tables, and work with your SQL Server Express database that way.

Robert Harvey
From what I saw of SQL Server Express, it is not portable - it needs to be installed on a particular machine, and cannot be simply copied and pasted to a different location.
ZevSpitz
Is the ability to move the database around a requirement of your application?
Robert Harvey
Yes, it is. It is also one of the reasons we are using an HTA - since I can't tell in advance which OS or which version of Access we will be using. (The program is intensively used for a sale of items at wholesale prices, which takes place about once a month, and even though there is a fixed pool of laptops used, it is quite possible that additional ones may be borrowed.)
ZevSpitz
Either ADO or DAO will work just fine, and you can use both of them in the same application if you want to.
Robert Harvey
A: 

If you can afford to use a HTA application with Access instead of a more performant platform, I would say you should go with the easiest api for you. The bottleneck will never be the abstraction of db access in your case. Still, DAO is really old.

artificialidiot
A: 

You can also use JRO to compact your MDB file. This will be included with any recent version of MDAC, installed by default on XP and later systems. No installation of Access is necessary.

To answer your specific questions:

1) I would opt for ADO just because it is more current, and the same API can be used in other kinds of scripting, like LDAP/ActiveDirectory access, reading file system folders, reading MAPI mail, and working with other types of semi-structured text files like fixed width text and CSV. It's not specifically better for the HTA programming environment, but its perhaps better for you to learn a more widely applicable API. I also thinks it's an easier API to work with, but I started with it and only later worked on some older DAO projects.

2) One possible benefit that ADO provides is that of disconnected recordsets, which may have an advantage or at least suggest some architectural alternatives in your wireless network setup. You open a recordset, then disconnect it, so you can still work with the data in memory, but not have to leave a database connection open. Then at a later time you can reconnect and update the database. Also, you can work in a fully disconnected style by managing tables as local XML or ADTG files.

Todd
+1  A: 

You might shoehorn DAO into working from VBScript but that's an odd pairing. ADO makes the most sense in general.


Another advantage of ADO would be that it supports RDS over DCOM or HTTP. This can be used to overcome many of the limitations of Jet MDBs used via file sharing, such as the corruption unreliable networks and clients can lead to. It also cuts the amount of traffic over the network, improving performance. In addition it offers a middle tier in which business objects can "live" and all of this can be mediated using COM+ where applicable.

Of course you no longer have the option of using a simple P2P network and a file share to host the database. RDS needs a server to host the process and run the Jet engine, which no longer needs to run on each client system. This means you can use Jet stored procedures that run on the server, offloading more client processing and network traffic. While not as sophisticated as T-SQL or other alternatives, this ADO/Jet 4.0 OLE DB Provider exclusive technology offers tangible benefits that can't be had using DAO.

RDS can mask much of the process of using disconnected Recordsets, simplifying client code. It uses ADTG under the hood, which was developed and optimized for this very purpose.

However using RDS requires more infrastructure and expertise than a simple file share. You might as well look into a low-end version of SQL Server.


In general I'd recommend using the jetcomp.exe utility to compact and repair, over either DAO or JRO. It offers a number of advantages.

Bob Riemersma
I don't think DAO/VBScript is such an odd pairing; I've done it before.
ZevSpitz
Your point about jetcomp.exe is very interesting - I can open a Shell object, and execute it.
ZevSpitz
The benefits of a file share are that the HTA can be deployed into the share and run from all the peers. A simple refresh (F5) reloads the newly updated HTA. There is no installation; and the HTA is not locked while it is being executed, so it can be overwritten.
ZevSpitz
You're right, and this makes HTAs nice for creating lightweight applications, even multiuser applications. Some of the MDB corruption risk can be mitigated if your HTAs do not hold open connections too, connecting only to query or update and then closing. This costs in overhead and performance, but if activity is low and the network fast it might not be a big deal - and it keeps your HTA from holding "dirty" pages of the MDB that go uncommitted.
Bob Riemersma