saeed
saeed

Reputation: 673

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

Im using c# .net windows form application. i have a SQL database with 5 tables. i need to populate a combobox with these table names. only names should be displayed.

Upvotes: 0

Views: 983

Answers (2)

anonymous
anonymous

Reputation: 3544

From MSDN.

SELECT name FROM sys.tables;

Works for SQL Server 2005 and above.

Upvotes: 1

Matti Virkkunen
Matti Virkkunen

Reputation: 65166

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'

Upvotes: 1

Related Questions