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];
                    }
                }
            }

  • 相关阅读:
    二叉树的镜像
    Prototype 模式
    假如编程语言在一起聚餐
    从零开始——Ubuntu系统安装LAMP
    从零开始——Ubuntu系统配置与软件安装
    从零开始——制作Ubuntu系统U盘启动
    apt-get upgrade failure with libc
    再生龙Clonezilla备份Ubuntu系统
    Ubuntu上apache多端口配置虚拟主机的方法
    bash & Makefile & 正则表达式学习
  • 原文地址:https://www.cnblogs.com/Demcia/p/3989974.html
Copyright © 2011-2022 走看看