简体   繁体   English

如何使用c#在组合框中从数据库获取所有表的名称

[英]How get the names of all the tables from a database in a combo box using c#

Im using c# .net windows form application. 我正在使用c#.net Windows窗体应用程序。 i have a SQL database with 5 tables. 我有一个带有5个表的SQL数据库。 i need to populate a combobox with these table names. 我需要用这些表名填充一个组合框。 only names should be displayed. 仅显示名称。

Can't know for sure until you specify what you're using, but this is a more or less standard query for retrieving the table names (excluding views) in the current database: 在指定您要使用的内容之前无法确定,但这是用于检索当前数据库中的表名(不包括视图)的或多或少的标准查询:

SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'

From MSDN . 来自MSDN

SELECT name FROM sys.tables;

Works for SQL Server 2005 and above. 适用于SQL Server 2005及更高版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM