For those of you who have been around ASP for a while, you're probably
saying: "He's lost his mind... no one would write an entire article on
this." Well that's what I've been saying for the last couple years and
yet it's still one of the most frequently asked questions for new users
who are trying to learn from other people's code. So in an effort to
address the question once and for all in an easy to find location I'm
making it an article and there's not too much you can do to stop me! ;)
For those of you who are new to ASP, or in other words those of you still reading,
read on brave souls. Hopefully I'll be able to shed some light on the subject for you. Or at
very least I'll explain it yet again so it's in yet another place so
maybe it'll be found by the search engines.
First of all, what the heck is a .inc file anyway?
An .inc file is normally just an include file. An include file is a
way to take the same set of code and reuse it in a number of ASP
scripts. Most people have switched to using .asp for the extension
of their include files for a number of reasons, but originally a lot
of users named their include files .inc as an easy way to differentiate
them from their other file types. So this was the extension originally
given to the file and it's stuck ever since then.
For more information on why includes
are now named .asp and a ton of other great information on includes
check out
The low-down on #includes
over at 4GuysFromRolla.
Okay... so that explains the .inc. What's Adovbs mean?
Adovbs is an abbreviation for ActiveX Data Objects (ADO) for Visual
Basic Script (VBS or VBScript). ADO is one of the most commonly used
data access interfaces used with ASP and VBScript is the most commonly
used scripting language. If you're doing database access from an ASP
page, you're almost certainly using ADO and most of you are doing that
using VBScript. Together they give us the name for one of the
most commonly questioned files. ;)
So if there's one for VBScript shouldn't there be one for JScript too?
Funny you should ask because there is. It's called adojavas.inc. It
contains all the exact same constants, but they're declared using JScript
instead of VBScript.
So now I know where the name comes from, but what is it?
(The author finally stops rambling and gets to the point!)
Well there's really not much to it and to prove there's no magic involved
I'm going to show you the file!
(Screams of fear come from the croud as we open the mystical file!)
Here's a piece of the latest version I could find (there will be more on finding your copy later):
As you can see it's just a long list of constants.
15K worth to be precise... hence the abbreviated version above.
That's all it is.
Ok wiseguy... enough already. What does it do and why should I care?
Like I mentioned earlier, when you write database related code in ASP,
you're really using ADO (ActiveX Data Objects). In order to use ADO
effectively, you
need to give it some input in order for it to work the way you want it to.
In order for ADO to know what you're talking about you need to talk to it
on it's level. Being a computer program and all, ADO only understands lots of
numbers and weird
looking things like this: &H00000200 (still a number, just a different type).
Well... an asp script with all sorts of numbers and weird looking things isn't
very easy to write or read back later when you need to debug it. So in order
to keep things easy for both the programmer and the computer to understand
there's a dictionary which converts pseudo-english words into computer-friendly
numbers.
You've got it... this dictionary is contained in the adovbs.inc file.
It defines a type of "language" which makes
communication with ADO easier. The end result is that by using adovbs.inc, you
write more readable and easier to follow ASP code.
So to recap, the adovbs.inc file contains a list of all the named ADO constants and
their numerical equivilents. When included in your ASP code, it defines them as
constants so you have access to them in your code. There are a lot of these
constants and most code you will see only uses a very small subset of them, but
some you might recognize are adOpenStatic, adLockReadOnly, adCmdText, etc...
For illustration here's a simple line from a database script written first
using the constants and second without using the constants:
ASP & ADO code written assuming adovbs.inc is included:
ASP & ADO code written assuming adovbs.inc is not included:
rstTest.Open strSQL, cnnTest, 3, 1, &H0001
As you can easily see, it's much easier for the reader to determine that
the recordset is being opened using a static cursor with a read-only lock type and
that strSQL is a SQL text query by looking at the first line then it is by
looking at the second.
So once you've used this file to write a script, the reason the code doesn't work when you forget
to include the file is that ADO has no idea what the heck you're talking about.
Without the inclusion of the dictionary, it has no way to figure out what number
the constants you've used in the code are supposed to correspond to. The result is that incorrect
values get passed to ADO and it doesn't know what to do with them and usually breaks.
Okay so where do I get a copy and how do I use it?
In terms of getting a copy, you probably already have one! Do a search on your
system for adovbs.inc and you'll almost certainly find the copy that was
installed with your version of ADO. If you can't find one, you can get a copy
of the one I'm currently using here. If you're using
JScript, you'll probably want adojavas.inc too.
(For both of those you might want to right click and do a
"Save Target As..." or "Save Link As..." depending on your
browser of choice.)
Note: Some people were having trouble downloading the files so I've changed
the filenames to adovbs.inc.txt and adojavas.inc.txt. Once you get them, simply
remove the .txt extension and you should be all set.
Using it is almost as easy. Simply include the file in your ASP page. The
syntax is the same as any other include file and should look something like this:
<!-- #include file="adovbs.inc" -->
Once that's done you can start using the more readable adConstant style of constant
(like adOpenDynamic and adLockOptimistic) instead of their corresponding numbers.
That's all...
That's the not so quick run down of everything you ever wanted to know about
adovbs.inc but were afraid to ask. Now you know why you were afraid... someone
like me might just tell you!