从读取web.config文件的价值? [英] Reading value from web.config file?

查看:112
本文介绍了从读取web.config文件的价值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从我DAL,如何从web.config中读取连接字符串?

From my DAL, How can i read a connection string from the web.config?

推荐答案

您可以使用WebConfigurationManager读取web.config中的连接字符串值

You can use the WebConfigurationManager to read connection string value from web.config

code示例:

using System.Configuration;

string connString = WebConfigurationManager.ConnectionStrings["ConnectionString"].ToString();

请确保您已经添加了System.configuration引用您的DAL。

Make sure you have added the System.configuration reference to your DAL.

这篇关于从读取web.config文件的价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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