如何在经典ASP中设置和获取web.config中的连接字符串? [英] How to set and get the connection string from web.config in classic ASP ?

查看:48
本文介绍了如何在经典ASP中设置和获取web.config中的连接字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我如何设置并从经典asp中的web.config获取连接字符串。



提前谢谢



我尝试了什么:



有人可以告诉我如何设置和获取连接字符串来自经典asp。中的web.config。

Can somebody please tell me how to set and get the connection string from web.config in classic asp.

Thanks in advance

What I have tried:

Can somebody please tell me how to set and get the connection string from web.config in classic asp.

推荐答案

经典的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


这篇关于如何在经典ASP中设置和获取web.config中的连接字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆