<?xml version="1.0" encoding="GB2312"?>
<component>
<?component error="true" debug="false"?>
<registration description="DatabaseManager" progid="Site.DBManager" version= "1.00" classid= "{753f5856-0875-48ef-8e1c-20018e63f705}"></registration>
<public>
<property name="Description">
<get/>
</property>
<method name="ConnectionString">
<PARAMETER name="DBName"/>
</method>
<method name="OnStartPage">
<PARAMETER name="ScriptContext "/>
</method>
<method name="OnEndPage">
</method>
</public>
<implements type="ASP" id="ASP"/>
<resource id="description">用于存放所有数据库连接字符串的脚本部件</resource>
<resource id="conn1">Driver={SQL Server};Provider=sqloledb;SERVER=localhost;UID=123;PWD=123;DATABASE=db</resource>
<resource id="conn2">Driver={SQL Server};Provider=sqloledb;SERVER=localhost;UID=123;PWD=123;DATABASE=db</resource>
<script language= "VBScript">
<![CDATA[
dim bASPImplement
function get_Description()
get_Description = getResource( "description")
end function
function ConnectionString(DBName)
if bASPImplement then ConnectionString = getResource(DBName)
end function
function OnStartPage(ScriptContext)
bASPImplement = true
end function
function OnEndPage()
end function
]]>
</script>
</component>
==================================================
以上自己稍加修改后存为文件名 conn.wsc ,然后把文件扔在一个别人不容易找到的地方。在上面右键点注册
调用的办法
Set oDBManager = Server.CreateObject( "Site.DBManager ")
sConnectionString = oDBManager.ConnectionString( "conn1 ")
set oDBManager = nothing
Conn.Open sConnectionString