当前位置:首页 > ASP教程 > ASP类

解析ASP,NET MVC 中 web.config XML文件 取出数据库类型

         /// <summary>
        /// 解析web.config   查询dbType类型
       /// </summary>
 
        private static void SetDBType()
        {
            #region 解析web.config   查询dbType类型
            string strPath = HttpContext.Current.Server.MapPath("/") + "Web.config";
            XmlDocument doc = new XmlDocument();
            doc.Load(strPath);
            string dbType = "";
            XmlNodeList nodeList = doc.SelectNodes(@"configuration/appSettings/add");
            foreach (XmlNode nodeitem in nodeList)
            {
                if (nodeitem.Attributes["key"] != null && nodeitem.Attributes["value"] != null)
                {

                    if (nodeitem.Attributes["key"].Value.ToString() == "DBType")
                    {
                        dbType = nodeitem.Attributes["value"].Value;
                    }
                }
            }

           
            #endregion
        }

  

解析ASP,NET MVC 中 web.config XML文件 取出数据库类型

标签:

本文系统来源:http://www.cnblogs.com/zemax/p/5667680.html


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!