AppSettings和ConnectionStrings的区别
在 .NET Framework 2.0中,ConfigurationManager类新增了两个属性AppSettings和ConnectionStrings专门用来获取配置文件AppSettings和ConnectionStrings节的数据,使用方法如下:
using System.Configuration;
public partial class _Default :
System.Web.UI.Page
{
protected
void Page_Load(object sender, EventArgs e)
{
Label1.Text =
ConfigurationManager.ConnectionStrings["connectionStringsName"].ToString();
Label2.Text =
ConfigurationManager.AppSettings["appSettingsName"].ToString();
}
}
<connectionStrings>和<appSettings>这个的区别
1.<connectionStrings>
<connectionStrings>
<add name="SYXTConnectionString"
connectionString="Data Source=LEIKE;Initial Catalog=SYXT;User
ID=sa;Password=sa"
providerName="System.Data.SqlClient" />
</connectionStrings>
2.<appSettings>:
<add key="connectionstring1" value="data
source=192.168.123.201;initial catalog=webmedlink;persist security
info=False;user id=sa;password=KSDChagd2004;packet
size=4096">
</add>