且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在经典ASP中设置和获取web.config中的连接字符串?

更新时间:2022-11-05 11:49:39

经典的asp web.config - Google搜索 [ ^ ]


可以尝试使用此代码:



但这是勺子提要你试过Google吗?你需要遍历web.config中的节点。



May try this for your code:

But this is spoon feed have you tried Google. You need to iterate through the nodes in web.config.

set xmlDoc=server.CreateObject("Microsoft.XMLDOM")
set xmlappSettings=server.CreateObject("Microsoft.XMLDOM")
set xmladd=server.CreateObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.load(server.MapPath ("web.config"))
set xmlappSettings = xmldoc.GetElementsByTagName("appSettings").Item(0) 
set xmladd = xmlappSettings.GetElementsByTagName("add")
for each x in xmladd 
'Check for the Atrribute Value
if  x.getAttribute("key") ="ConnectionString1" then
Response.write(x.getAttribute("value"))
end if
next