从数据库获取所有表的列表
问题描述:
如何从数据库的列表框控件中获取所有具有其名称的表的列表?
How to get list of all tables with their names in a listbox control from Database ?
答
这很简单,但这取决于什么您使用的数据库系统.
尝试使用SQL:
It''s quite simple, but it will depend on what DB system you use.
Try the SQL:
SELECT * FROM INFORMATION_SCHEMA.TABLES
现在,另一种选择是使用ado.net连接到数据库并调用
And now the aternative option is using your ado.net connection to your database and calling
connection.GetSchema("Tables")
然后您可以填充一个DataTable并将数据绑定到您的UI中
有关示例,请参见此处的msdn
and you can populate a DataTable and data bind to that in your UI
for examples see msdn here