国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

一種比使用include adovbs.inc更好的方法,請看(Using METADATA to

2024-07-21 02:15:36
字體:
來源:轉載
供稿:網友
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:

<!--#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

   '...
%>




we can use the metadata tag in place of the <!--#include virtual="/adovbs.inc"-->. the metadata tag has the following form:

<!--metadata
     type="typelib"
     file="filename"
     uuid="tylelibraryuuid"
-->




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:

<!-- metadata
        type="typelib"
        uuid="00000200-0000-0010-8000-00aa006d2ea4"
-->




and

<!-- metadata
        type="typelib"
        file="c:/program files/common files/system/ado/msado20.tlb"
-->




you can then place this metadata tag in place of the #include. for example, the first script we examined would be changed to:

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

   '...
%>




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 <script ...> block in global.asa. (it doesn't have to be placed there, but why not do that, just to make me happy?)

anyway, besides saving typing and having to include adovbs.inc in all of your pages that need to access ado constants, using metadata supposedly increases performance. at least according to microsoft. all i could find regarding the performance boost was one sentence- no benchmarks, no hard numbers. the sole sentence reads as follows:

"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"
-- taken from asp performance tips
a couple of caveats: first, from alert reader daniel s., if you include adovbs.inc when using the metadata tag in global.asa, you will get a name redefined error. second, the metadata tag will only work with iis 4.0 and up.

comments from alert reader rohan p.
i was just looking at the article using "met


|||adata to import dll constants". there are a couple of points worth bearing in mind.
firstly, you can import any type libray constants into global asa, not just the ado ones. i also import the filesystemobject and cdo constants this way.

secondly, visual interedev 6 gives you a neat way of doing it without needing to either know the guid of the type libray, or referencing the dll directly. just go to projects - references. all the type libraries are listed there, and when selected, will automatically get written into global asa!



well, there you have it. happy programming!





發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 民权县| 阳西县| 东宁县| 隆德县| 西平县| 上饶县| 偃师市| 股票| 苏州市| 那曲县| 军事| 德令哈市| 邛崃市| 兰西县| 深泽县| 石河子市| 奉新县| 汝城县| 绥宁县| 弥渡县| 印江| 仙居县| 赤水市| 叙永县| 青阳县| 乌鲁木齐县| 友谊县| 博客| 利津县| 清苑县| 海伦市| 油尖旺区| 吴江市| 丰县| 潮州市| 九龙县| 乐亭县| 太和县| 自贡市| 哈尔滨市| 南涧|