ASP 101 - Active Server Pages 101 - Web05
The Place ASP Developers Go!

Please visit our partners


Windows Technology Windows Technology
15 Seconds
4GuysFromRolla.com
ASP 101
ASP Wire
VB Forums
VB Wire
WinDrivers.com
internet.commerce internet.commerce
Partners & Affiliates














ASP 101 is an
internet.com site
ASP 101 is an internet.com site
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

ASP 101 News Flash ASP 101 News Flash



 Top ASP 101 Stories Top ASP 101 Stories
The Top 10 ASP Links @ Microsoft.com
What is Adovbs.inc and Why Do I Need It?
An Overview of ASP.NET

QUICK TIP:
Connection Pooling lightens the load
Show All Tips >>
ASP 101 RSS Feed ASP 101 Updates


Using Type Libraries Instead of Adovbs.inc

Using Type Libraries Instead of Adovbs.inc

by John Peterson

Introduction

I get a lot of questions here at ASP 101 regarding the use of the adovbs.inc file. Last week, I finally decided to do something about it and wrote an article entitled: What is Adovbs.inc and Why Do I Need It?. Moreover, I had been planning on following it up with another article explaining the downsides to using adovbs.inc and illustrating another method that I assumed was less well known.

Maybe it's more common knowledge then I was giving it credit for or maybe those of you who use it feel really vehemently about it, but whatever the cause... before I started to write the follow-up article, I was swamped with email outlining exactly what I had been planning on saying!

Therefore, instead of actually writing the article I was intending, I'm doing something a little different and am leaving the explanation to you guys/gals. Below you'll find a few of the extremely capable responses I received as feedback from last week's article. I've removed the names to protect the guilty! ;)

Note: If you're the author of one of the emails below and would like your name listed with your message, just drop me an email and it'll magically appear when I get around to it!

The Messages


Hello.

I saw your article on ASP101.com entitled "What is Adovbs.inc and Why Do I Need It?".

The use of the .INC file is a bit out dated. Most developers I have worked with use the Type Library in the global.asa file.

Example:

<!--METADATA
TYPE="TypeLib"
NAME="Microsoft ActiveX Data Objects 2.6 Library"
UUID="{00000206-0000-0010-8000-00AA006D2EA4}"
VERSION="2.6"
-->

This is the latest type library. For compatibility with most projects, we usually use version 2.0. The additional Include file is not needed since all information is held within the DLL itself. If additional versions of ADODB come out, you would simply change the UUID. You can either place this file within your global.asa file, or on the page that has database access. It is cross-language compatible.

I usually type this in by hand, but If you are new to loading type libraries, then Microsoft Interdev has an easy way to help you add them. Follow this simple process.

  1. After you load your project, go up to the menu and click Project.
  2. Click on Project References ... at the bottom.
  3. Scroll down the available references until you Find Microsoft ActiveX Data Objects 2.0 Library (or the version that you prefer) and put a check in the checkbox.
  4. Click Ok.

Look in your global.asa file. You will see that InterDev has added this metadata for you near the top of your page.

Now, when you type ADODB followed by a period, you will get a list of the available enumerations available within the type library. Note: the name does not "have" to be prefixed by ADODB. I just do this so that other programmers who have not worked with these variables would be more likely to ask me about what ADODB means. It also gives the project a more Object-Oriented feeling.

<%
' Without ADODB Prefix
rstTest.Open strSQL, cnnTest, adOpenStatic, _
    adLockReadOnly, adCmdText
' With ADODB Prefix
rstTest.Open strSQL, cnnTest, ADODB.adOpenStatic, _
    ADODB.adLockReadOnly, ADODB.adCmdText
' Using With
With ADODB
    rstTest.Open strSQL, cnnTest, .adOpenStatic, _
        .adLockReadOnly, .adCmdText
End With
%>
Lewis Moten - http://www.lewismoten.com

Greetings - I'm on the list for ASP101.com - I received an email this morning about the ADOVBS file. I have recently discovered a much better solution, for those who don't mind having a global.asa file on their server. If you use InterDev, open a project and select "Project -> References" from the toolbar. Select ADO 2.5 and RDO. InterDev adds some meta tags to the global.asa file so you don't need to include the adovbs.inc file. I haven't done any serious testing, but my guess would be less overhead because the server is not reading the include file for each call. There's also a reference for "Scripting..." so you can use the FileSystemObject and pick all those "ForReading" "ForWriting" etc... without defining them. Here's the meta tags that InterDev adds them incase you don't have access to it:

Remote Data Services:

<!--METADATA TYPE="TypeLib" NAME="Microsoft Remote Data Services Server 2.5 Library" UUID="{9381D8F6-0288-11D0-9501-00AA00B911A5}" VERSION="1.5"-->

ADO 2.5:

<!--METADATA TYPE="TypeLib" NAME="Microsoft ActiveX Data Objects 2.5 Library" UUID="{00000205-0000-0010-8000-00AA006D2EA4}" VERSION="2.5"-->

CDO for Windows 2000:

<!--METADATA TYPE="TypeLib" NAME="Microsoft CDO for Windows 2000 Library" UUID="{CD000000-8B95-11D1-82DB-00C04FB1625D}" VERSION="1.0"-->

Scripting Runtime:

<!--METADATA TYPE="TypeLib" NAME="Microsoft Scripting Runtime" UUID="{420B2830-E718-11CF-893D-00A0C9054228}" VERSION="1.0"-->

MS XML v3.0:

<!--METADATA TYPE="TypeLib" NAME="Microsoft XML, v3.0" UUID="{F5078F18-C551-11D3-89B9-0000F81FE221}" VERSION="3.0"-->

You can also add your own custom type libraries for custom built objects.

Enjoy!


Hi John,

First off let me say that I love your site. It is a great reference and I use it all the time.

I recently came across your article "What is Adovbs.inc and Why Do I Need It?"

While using the adovbs.inc is an acceptable practice, it is generally not considered the best option for integrating standardized ADO constants. The reason being is that the .inc file is rather large. Sometimes over 16K. Your ASP page must read this in whenever it runs and most of it is constants that you will never use anyway.

The better option is to use this line:

<!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common Files\System\ado\msado15.dll" -->

at the beginning of your page.

This is a .dll that contains all the ADO constants. Your ASP page has access to them all, but it only accesses what it needs.

You just need to make sure that you put the correct path to the dll. The above is the default path though.


Good article, now that you've explained it's uses, you might want to write a followup on how to use the METADATA tag in global.asa to eliminate the Include of that file everywhere. Or just link to this article for more info:

http://www.4guysfromrolla.com/webtech/110199-1.shtml

FYI, at my company, we've been using this tag:

<!-- METADATA TYPE="TypeLib" FILE="C:\Program Files\Common Files\system\ado\msado15.dll" -->

instead of the one recommended in the above file (which also works on our NT4 servers):

<!-- METADATA TYPE="TypeLib" FILE="C:\Program Files\Common Files\System\ADO\msado20.tlb" -->

I'd guess the one we're using is out of date, but we haven't run into a constant we needed to use which wasn't also in the older ADO 1.5 standard... On Win2K machines, msado21.tlb is installed as well.


Of course, an alternative to including adovbs.inc ( at least for ADO constants ), is to include the type library in your global.asa as follows :

<!--METADATA TYPE="TypeLib" NAME="Microsoft ActiveX Data Objects 2.5 Library" UUID="{00000205-0000-0010-8000-00AA006D2EA4}" VERSION="2.5"-->

This loads the type library for ADO into the memory space for your application, which should improve performance since you don't have to do an expensive include whenever you need access to these constants...


Good article. One thing that I think you should have mentioned, and that I had much later found out after including the adovbs.asp (I renamed my extension for good reason if you read about it). With the line

<!--METADATA TYPE="TypeLib" NAME="Microsoft ActiveX Data Objects 2.0 Library" UUID="{00000200-0000-0010-8000-00AA006D2EA4}" VERSION="2.0"-->

at the top of the global.asa you will avoid those includes. To be noted: if you are converting to this method, be sure to remove all adovbs.asp includes as you will get an error. Since you are trying to reassign a variable that is in the global.asa.


John,

I was just reading your article about ADOVBS.INC. You might want to also mention that you can do away with adovbs.inc being included in every file by inserting the following into the top of the GLOBAL.ASA file.

<!--METADATA TYPE="TypeLib" NAME="Microsoft ActiveX Data Objects 2.5 Library" UUID="{00000205-0000-0010-8000-00AA006D2EA4}" VERSION="2.5"-->
<!--METADATA TYPE="TypeLib" NAME="Microsoft ADO Ext. 2.5 for DDL and Security" UUID="{00000600-0000-0010-8000-00AA006D2EA4}" VERSION="2.5"-->

Obviously, the UUID and Version numbers must be changed depending on what version the server has installed.

I really like all the work that gets done at ASP101. Very good site.


Conclusion

While adovbs.inc can be a useful tool, it's not the only tool in the toolbox and may not even be the right tool for you!

With that final note and a hearty thank you to our audience for writing this article... I'm signing off and await your email for the next article! ;)

Related Links


Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers