app.config 信息如下
<?xml version="1.0" encoding="utf-8" ?><configuration> <configSections> <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" > <section name="Model.set" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> </sectionGroup> </configSections> <userSettings> <Model.set> <setting name="Connection" serializeAs="String"> <value>Data Source=192.168.0.254;Initial Catalog=DB;User ID=fhz;Password=fhzadmin;</value> </setting> <setting name="Path" serializeAs="String"> <value>D:\code\</value> </setting> </Model.set> </userSettings></configuration>
怎么读取呢????
ConfigurationManager.AppSettings["Connection"].ToString();
读不到呃
5 回答
慕后森
TA贡献1802条经验 获得超5个赞
<appSettings>
<add key="Connection" value="Data Source=192.168.0.254;Initial Catalog=DB;User ID=fhz;Password=fhzadmin;" />
</appSettings>我记得是这样写的。。。要不我也不知道怎么读取
慕容708150
TA贡献1831条经验 获得超4个赞
应该能读到的一般情况下ConfigurationManager.AppSettingd[""].Tostring();或者ConfigurationManager.ConnecString.Tostring();来读取的
呼如林
TA贡献1798条经验 获得超3个赞
app.config 应该这样写吧
<appSettings>
<add key="Connection" value="Data Source=192.168.0.254;Initial Catalog=DB;User ID=fhz;Password=fhzadmin;" />
</appSettings>
qq_遁去的一_1
TA贡献1725条经验 获得超7个赞
string connection=ConfigurationManager.AppSetting["Connection"].ToString();
- 5 回答
- 0 关注
- 409 浏览
添加回答
举报
0/150
提交
取消