获取数据库中所有表的名称 [英] Take the names of all Tables in a Database

查看:117
本文介绍了获取数据库中所有表的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在数据库(sql server)中获取表的所有名称,并为每个表创建一个标签页。



I want to take all the names of tables in a database (sql server), and create a tab page for each..

public void FillTabControl(TabControl tabControl)
        {

            sqlQuery = @"SELECT * FROM SYSOBJECTS WHERE XTYPE='U'";

            con = fdc.NewConnection();
            command = new SqlCommand(sqlQuery, con);

            try
            {
                con.Open();

                sqlReader = command.ExecuteReader();

                while (sqlReader.Read())
                {
                    tabPage = new TabPage(sqlReader.GetName(0));
                    tabControl.TabPages.Add(tabPage);
                }

            }
            catch
            {

            }
            finally
            {
                con.Close();
            }
        }





我需要一个带有TABLE NAME的字符串,它不起作用......我怎么读这个命令的输出?



I need a string with the TABLE NAME, it doesn't work... How i read the output of this command ?

推荐答案

你还谷歌了吗? [ ^ ]



[update]

Did you Google for, yet?[^]

[update]
Quote:

好的,我已经知道选择所有表的查询,但我不知道如何读取输出在C#中查询此查询以了解每个表的名称...

Ok, i already know the query to select all tables, but i doesn't know how to read the output of this query in C# to know the names of each table...

然后谷歌更好! [ ^ ]

[/ update]


这篇关于获取数据库中所有表的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆