The way to end Adovb.inc

Source: Internet
Author: User
ADO I see an article abroad, now translates as follows ... It certainly helps.

One drawback of ASP is that when we are using a component, we are not going to get it.
For example, when you want to use ADO, you must first include the Adovbs.inc file
Or do a similar job, look at the following code:

<!--#include virtual= "/adovbs.inc"-->
<%
Dim objconn, strSQL
Set objconn = Server.CreateObject ("ADODB. Connection ")
objConn.Open "Dsn=blah"

strSQL = "SELECT * FROM Table1"

Dim objRS
Set objRS = Server.CreateObject ("ADODB. Recordset ")
Objrs.open strSQL, objconn, adOpenKeyset

'...
%>

Now let's try another way.
Use metadata label

The label is formatted as follows:
<!--METADATA
Type= "TypeLib"
File= "FileName"
Uuid= "Tylelibraryuuid"
-->

First, you need set type= "TypeLib", where the file and UUID two can only be specified one.
You can specify a TLB or DLL file directly to the file property.
For example, on my machine, I did this:

<!--METADATA
Type= "TypeLib"
Uuid= "00000200-0000-0010-8000-00AA006D2EA4"
-->

And

<!--METADATA
Type= "TypeLib"
file= "C:\Program Files\Common Files\system\ado\msado20.tlb"
-->

Now let's take a look at how to replace the Adovbs.inc file
Replace with the following code where you originally included the file:
<!--METADATA
Type= "TypeLib"
file= "C:\Program Files\Common Files\system\ado\msado20.tlb"
-->

<%
Dim objconn, strSQL
Set objconn = Server.CreateObject ("ADODB. Connection ")
objConn.Open "Dsn=blah"

strSQL = "SELECT * FROM Table1"

Dim objRS
Set objRS = Server.CreateObject ("ADODB. Recordset ")
Objrs.open strSQL, objconn, adOpenKeyset

'...
%>


However, I originally used Adovbs on the original page. Inc Well, why use so long a code, too cumbersome, yes, is a bit of trouble, but you can put this code in the Global,asa, so you can use application to get a global variable.
Be careful to put it inside the <SCRIPT> block.

Let's take a look at what Microsoft says, I've only found an article that can be summarized as follows:

The avoid using Server-side #include directives to include large lists of constants. Use the ' new <METADATA> tag to ' import Type-library constants into Global.asa '

This is the original.
Http://msdn.microsoft.com/library/psdk/bdg/bdgapp03_3rhv.htm

Two points to be aware of where you are in global. ASA uses metadata, while you use ADOVBD at the same time. Inc., you'll get an error.
The second is that the method requires at least IIS4 support.

I wish I could be of some help to you.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.