|
Avoid ADOVBS.INC
By Steven Smith
Just say NO to using ADOVBS.INC in your ASP pages. It's not the right way to do things.
It requires an include file in *every* page that uses any ADO constants. Include files
impose overhead -- significant in sites that see a great deal of traffic. Furthermore,
this file is fairly long, including all kinds of constants of which any one page will
probably only use one or two. There is a better way.
With ASP 2.0, Microsoft introduced typelib access into ASP. You can reference a typelib
declaratively in your ASP page using the following METADATA syntax. This particular line
is for ADO 2.5, which includes all of the constants found in adovbs.inc.
<!--METADATA TYPE="TypeLib" NAME="Microsoft ActiveX Data Objects 2.5 Library" UUID="{00000205-0000-0010-8000-00AA006D2EA4}" VERSION="2.5"-->
I know what you're thinking. Ok, so what's the big deal?
Instead of one include file I now have to remember this
weird new syntax with a GUID? No thanks.
I could tell you that typelibs are much better from a performance standpoint, but
most sites honestly won't notice any difference either way. The real clincher is that
you can put the typelib call in your global.asa and ALL pages in your application can
use constants defined in that typelib (try it -- just copy and paste the line above
into your global.asa and remove your adovbs includes). No more frustration when a page breaks because
you forgot to include the adovbs.inc file. Everything is in one place, where it should be,
in the global.asa.
A couple of last remarks, based on feedback I've received from this article. First,
this is not something unique to ADO 2.5. You can add typelib information from any COM
component to which you have access to the typelib. Second, the easiest way to do this
is with Visual Interdev. Open your website, select Project -- Project References.
Check the box for Microsoft ActiveX Data Objects version you prefer. Just for
the sake of having the most recent information available, here is the code to add for
MDAC 2.6:
<!--METADATA TYPE="TypeLib" NAME="Microsoft ActiveX Data Objects 2.6 Library" UUID="{00000206-0000-0010-8000-00AA006D2EA4}" VERSION="2.6"-->
Note that the list you see in Visual Interdev is based on what is installed on your
development workstation, not necessarily what is available on the server. If you
choose a TypeLib that is not on the server, your application will fail with an error
similar to this one:
Active Server Pages error 'ASP 0223'
TypeLib Not Found
/stevesmith/global.asa, line 3
METADATA tag contains a Type Library specification that does not match any
Registry entry.
|