文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>根据服务名称,获取sql server 里的数据库表名

根据服务名称,获取sql server 里的数据库表名

时间:2011-02-15  来源:我的食草堂

public List<string> GetMSSQLDBNameList(string DSN, string UID, string PWD)
        {
           List<string> databases=new List<string> ();
            SqlConnection Connection = new SqlConnection(String.Format("Data Source={0};Initial Catalog=master;User ID={1};PWD={2}", DSN, UID, PWD));
            DataTable DBNameTable = new DataTable();

//从系统表master..sysdatabases中查询数据库名字
            SqlDataAdapter Adapter = new SqlDataAdapter("select name from master..sysdatabases", Connection);
            Adapter.Fill(DBNameTable);

            foreach (DataRow Row in DBNameTable.Rows)
            {
                databases.Add(Row[0].ToString());
            }

            return databases;
        }
         public List<string> GetMSSQLDBNameList(string DSN)
         {
             List<string> databases = new List<string>();
             SqlConnection Connection = new SqlConnection(String.Format("Data Source={0};Initial Catalog=master;Integrated Security=True", DSN));
             DataTable DBNameTable = new DataTable();
             SqlDataAdapter Adapter = new SqlDataAdapter("select name from master..sysdatabases", Connection);
             Adapter.Fill(DBNameTable);

             foreach (DataRow Row in DBNameTable.Rows)
             {
                 databases.Add(Row[0].ToString());
             }

             return databases;
         }

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载