public string GetConStr()
    {
        try
        {

            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(Server.MapPath("App_Data\\config.xml"));
            XmlNode node1 = xmlDoc.SelectSingleNode("configuration/ConnectionStrings1/DataSource");
            XmlNode node2 = xmlDoc.SelectSingleNode("configuration/ConnectionStrings1/uid");
            XmlNode node3 = xmlDoc.SelectSingleNode("configuration/ConnectionStrings1/pwd");
            string strcon = "Data Source=" + node1.InnerText + ";uid=" + node2.InnerText + ";pwd=" + node3.InnerText;
            return strcon;
        }
        catch
        {
            Response.Redirect("Config.aspx");
            return null;
        }
    }

 

调用

IConfig iconfig = new IConfig();

iconfig .GetConStr();

 

posted on 2009-11-19 15:12  独孤伊雪  阅读(460)  评论(0编辑  收藏  举报