获取数据库中指定类型的数据库名称

  /// <summary>
        /// 获取数据库名称
        /// </summary>
        /// <param name="Account">帐套号</param>
        /// <returns></returns>
        public static string GetDBName(string Account)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(" select name from master..sysdatabases where name like'%UFDATA_%' ");
            DataSet ds = DbHelperSQL.Query(strSql.ToString());
            int count = ds.Tables[0].Rows.Count;
            string DbName = string.Empty;
            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    DbName = ds.Tables[0].Rows[i]["name"].ToString();
                    string TempDbName = DbName.Substring(7, 3);
                    if (Account == TempDbName)
                    {
                        return DbName;
                    }
                }
            }
            return DbName;
        }

 

posted @ 2016-06-28 09:33  Akon.Ray  阅读(279)  评论(0编辑  收藏  举报