当前位置:Gxlcms > 数据库问题 > 解析ASP,NET MVC 中 web.config XML文件 取出数据库类型

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

时间:2021-07-01 10:21:17 帮助过:2人阅读

         /// <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文件 取出数据库类型

标签:

人气教程排行