C#中获取字符串

Winform程序App.Config里.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Connect_String" value="user id=***;data source=***;password=***"/>
</appSettings>
</configuration>

读取的时候:
string connectionString = System.Configuration.ConfigurationSettings.AppSettings.Item("Connect_String")



----------------------------------------------------------------------------------------------------------
web.config里面 

<appSettings>
<add key="ConnString" value="Server=(local);database=test;uid=sa;pwd=123456"/>

</appSettings>

其他页面调用

string strconn = System.Configuration.ConfigurationManager.AppSettings["ConnString"];
posted @ 2013-06-14 15:16  shiney-zhang  阅读(703)  评论(0编辑  收藏  举报