zoukankan      html  css  js  c++  java
  • 获取配置文件数据库名称

          ReadConfig("Noah.BSP", ref connect, ref database);
               
                string TableName = database + ".dbo.OUM_Organization";

        /// <summary>
            /// xml读取配置文件
            /// </summary>
            private void ReadConfig(string DataBaseAlias, ref string connect, ref string database)
            {
                string ss = string.Empty;
                DataBaseAlias = DataBaseAlias.ToLower();
                string path = HttpRuntime.AppDomainAppPath + "\Inspur.Finix.config";
                XmlTextReader reader = new XmlTextReader(path); // new一个XMLTextReader实例 
                XmlDocument doc = new XmlDocument();
                doc.Load(reader);// 
                reader.Close();//关闭reader,不然config文件就变成只读的了 
                XmlNodeList nodeList = doc.SelectSingleNode("//components").ChildNodes;
                foreach (XmlNode n in nodeList)
                {
                    if (DataBaseAlias == n.Attributes["name"].Value.ToLower())
                    {
                        ss = n.FirstChild.Attributes["name"].Value;
                    }
                }  //end foreach

                if (!string.IsNullOrEmpty(ss))
                {
                    if (ss.Contains("server"))
                        ss = ss.Replace("server", "Data Source");
                    string[] strs = ss.Split(';');
                    if (strs.Length >= 4)
                    {
                        connect = strs[0] + ";" + strs[1] + ";" + strs[2] + ";";
                        database = strs[3].Split('=')[1];
                    }
                }
            }

  • 相关阅读:
    LeetCode 3Sum Closest
    LeetCode Jump Game
    LeetCode Convert Sorted List to Binary Search Tree
    LeetCode Search for a Range
    LeetCode ZigZag Conversion
    sql server中主键列的插入问题
    php 联系电话验证(手机和固话)
    Update与Mysql、Sqlsever中的随机数
    Yii在nginx下多目录rewrite
    php后台判断ajax请求
  • 原文地址:https://www.cnblogs.com/Demcia/p/3989974.html
Copyright © 2011-2022 走看看