文章导航PC6首页软件下载单机游戏安卓资源苹果资源

pc软件新闻网络操作系统办公工具编程服务器软件评测

安卓新闻资讯应用教程刷机教程安卓游戏攻略tv资讯深度阅读综合安卓评测

苹果ios资讯苹果手机越狱备份教程美化教程ios软件教程mac教程

单机游戏角色扮演即时战略动作射击棋牌游戏体育竞技模拟经营其它游戏游戏工具

网游cf活动dnf活动lol周免英雄lol礼包

手游最新动态手游评测手游活动新游预告手游问答

您的位置:首页精文荟萃软件资讯 → 一种比使用include adovbs.inc更好的方法

一种比使用include adovbs.inc更好的方法

时间:2004/10/7 19:08:00来源:本站整理作者:蓝点我要评论(0)


            
             
              
             
            

               
               

            



            Using METADATA to Import DLL Constants
One disadvantage of ASP is that when using a component, the component's constants aren't immediately avaialable. For example, if you want to use the ADO constant adOpenStatic you need to include adovbs.inc. While there is nothing wrong with this, wouldn't it be nice not to have to always be sure to include adovbs.inc each time that you wanted to use an ADO constant?

Your days of including adovbs.inc are over! The METADATA tag can be used to automatically import the constants from a DLL or TBL file. For example, imagine that we wanted to crate a recordset object with a Keyset cursor. We'd have to use code similar to:

处理 SSI 文件时出错

<%
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

'...
%>



We can use the METADATA tag in place of the 处理 SSI 文件时出错
. The METADATA tag has the following form:





First off, you need to set TYPE="typelib". Concerning the other two parameters, FILE and UUID, you need to only specify one. You can either specify the TBL or DLL file directly with the FILE property, or through the UUID. For example, on my machine, the following two statements would be identical:





and





You can then place this METADATA tag in place of the #include. For example, the first script we examined would be changed to:



<%
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, why would anyone want to use this longer METADATA tag on each page as opposed to the standard #include file="adovbs.inc"? Well, no one probably would want to do that. However, you can place the METADATA tag in your Global.asa file, which will give every ASP page in your web application knowledge of the ADO constants! Pretty sweet, eh? The METADATA tag should come before the