用vs2003中的办法报错。

解决方案 »

  1.   

    public void read()
    {
    string filename=Server.MapPath("") + @"\Web.config";
    XmlDocument  xmldoc= new XmlDocument();
    xmldoc.Load(filename); XmlNodeList topM=xmldoc.DocumentElement.ChildNodes;
    foreach(XmlElement element in topM)
    {
    if(element.Name=="appSettings")
    {
    XmlNodeList node=element.ChildNodes;
    if ( node.Count > 0 )
    {
    DropDownList1.Items.Clear();
    DropDownList2.Items.Clear();
    foreach(XmlElement el in node)
    {
    DropDownList1.Items.Add(el.Attributes["key"].InnerXml);
    DropDownList2.Items.Add(el.Attributes["value"].InnerXml);
    }
    }
    }
    }
    }Web.Config --------------------------------
    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <appSettings>
        <add key="Write" value="AA_Sams" />
        <add key="S.Sams" value="Modify_Sams" />
        <add key="wewewe" value="C_Modify_Sams" />
      </appSettings>
    </configuration>
      

  2.   

    private String conn=System.Configuration.ConfigurationSettings.AppSettings.Get("Write");
    就可以了。不用那么么烦
      

  3.   

    ren791123的方法在vs2003就可以,在vs2005中报错。
    s_sams的方法太烦,不是正解。
      

  4.   

    ren791123的方法在vs2003就可以
    --------------------------------
    那样可以在2005里用,出现绿色下化线,只不过警告,同样可以运行.兰色的是ERROR我也挺想知道正确方法的,关注一下
      

  5.   

    public static readonly string conn_Default = ConfigurationManager.ConnectionStrings["LoveyhConnectionString"].ConnectionString; // 系统默认数据库连接串
      

  6.   

    补充楼上的,ConfigurationManager 是的东西,需要实现引用 System.Configutation.Dll 才能使用
      

  7.   

    WindowsApplication6.Settings1.Default.XYZXYZ对应app.config文件中的
    ...
    <WindowsApplication6.Settings1>
                <setting name="XYZ" serializeAs="String">
                    <value>22240107</value>
                </setting>
    </WindowsApplication6.Settings1>
    ...怎么觉得看起来像是typed Dataset似的。