Re: Dynamically Creating DAO Object by mr_unreliable
mr_unreliable
Thu May 10 16:40:30 CDT 2007
djp wrote:
> I'm trying to determine what the version of DAO is and create an object
> for it.
hi djp,
If all else fails, you can always use a "brute force" approach.
By that, I mean looking through your registry, and testing
for the presence of each candidate, until you get a failure
(meaning that the version previous to the failure is present
-- while the version causing the failure is not).
Here is a sample script. In my (ancient) system, there are
only two DBEngines present, versions 35 & 36. And so, this
script fails when I try to read up version 37.
--- <snip> ---
Set WshShell = WScript.CreateObject("WScript.Shell")
bKey = WshShell.RegRead("HKCR\DAO.DBEngine.35\")
msgbox(bKey)
bKey = WshShell.RegRead("HKCR\DAO.DBEngine.36\")
msgbox(bKey)
bKey = WshShell.RegRead("HKCR\DAO.DBEngine.37\")
msgbox(bKey)
--- </snip> ---
Unfortunately, afaik, regread has no direct way of telling
you that a key is not present, other than throwing an error.
And so, you are going to have to trap the error to determine
where the script fails, and by implication, the latest
version of the DBEngine.
Also unfortunately, vbScript does not have very sophisticated
methods of trapping errors, so you are going to have to use
ON ERROR RESUME NEXT, and test the error object each time.
cheers, jw
____________________________________________________________
You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)