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 combob开发者_高级运维ox with these table names. only names should be displayed.
From MSDN.
SELECT name FROM sys.tables;
Works for SQL Server 2005 and above.
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'
精彩评论