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

本文介绍如何利用ASP中的METADATA标签自动导入DLL或TBL文件中的常量,以减少对adovbs.inc文件的依赖。通过在Global.asa文件中使用此标签,可以提高所有网页对ADO常量的访问效率,并可能提升性能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

marginwidth="0" marginheight="0" src="http://www.aiwo1314.com/googleAdsense/gd468_60.html" frameborder="0" width="468" scrolling="no" height="60" leftmargin="0" topmargin="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:

<!--#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 marginwidth="0" marginheight="0" src="http://www.aiwo1314.com/googleAdsense/gd468_60.html" frameborder="0" width="468" scrolling="no" height="60" leftmargin="0" topmargin="0">

'...
%>

 


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 FilesCommon FilesSystemADOmsado20.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 FilesCommon FilesSystemADOmsado20.tlb"
-->

<%
Dim objConn, strSQL
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "DSN=Blah"

strSQL = "SELECT * FROM Table1" marginwidth="0" marginheight="0" src="http://www.aiwo1314.com/googleAdsense/gd468_60.html" frameborder="0" width="468" scrolling="no" height="60" leftmargin="0" topmargin="0">

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

marginwidth="0" marginheight="0" src="http://www.aiwo1314.com/googleAdsense/gd336_280.html" frameborder="0" width="336" scrolling="no" height="280" leftmargin="0" topmargin="0">

内容概要:该论文探讨了一种基于粒子群优化(PSO)的STAR-RIS辅助NOMA无线通信网络优化方法。STAR-RIS作为一种新型可重构智能表面,能同时反射和传输信号,与传统仅能反射的RIS不同。结合NOMA技术,STAR-RIS可以提升覆盖范围、用户容量和频谱效率。针对STAR-RIS元素众多导致获取完整信道状态信息(CSI)开销大的问题,作者提出一种在不依赖完整CSI的情况下,联合优化功率分配、基站波束成形以及STAR-RIS的传输和反射波束成形向量的方法,以最大化总可实现速率并确保每个用户的最低速率要求。仿真结果显示,该方案优于STAR-RIS辅助的OMA系统。 适合人群:具备一定无线通信理论基础、对智能反射面技术和非正交多址接入技术感兴趣的科研人员和工程师。 使用场景及目标:①适用于希望深入了解STAR-RIS与NOMA结合的研究者;②为解决无线通信中频谱资源紧张、提高系统性能提供新的思路和技术手段;③帮助理解PSO算法在无线通信优化问题中的应用。 其他说明:文中提供了详细的Python代码实现,涵盖系统参数设置、信道建模、速率计算、目标函数定义、约束条件设定、主优化函数设计及结果可视化等环节,便于读者理解和复现实验结果。此外,文章还对比了PSO与其他优化算法(如DDPG)的区别,强调了PSO在不需要显式CSI估计方面的优势。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值