Click here to Skip to main content
15,895,370 members
Please Sign up or sign in to vote.
1.33/5 (2 votes)
See more:
How to get list of all tables with their names in a listbox control from Database ?
Posted
Comments
thatraja 1-Jan-11 8:11am    
You got the answer but always mention full details. you forgot to mention database here

It's quite simple, but it will depend on what DB system you use.

Try the SQL:
SELECT * FROM INFORMATION_SCHEMA.TABLES
 
Share this answer
 
Comments
#realJSOP 31-Dec-10 9:57am    
This is the answer.
OriginalGriff 31-Dec-10 10:19am    
Thanks John - I wasn't sure, I've never tried it on Oracle or Access.
Gareth Barlow (NBNi) 2-Jan-11 6:49am    
Wont work on oracle but you can use
"select * from user_tables" for schema level tables or

"select * from all_tables where schema_name = 'schema_name'" to get tables from a different schema
Abhinav S 2-Jan-11 7:05am    
http://davidhayden.com/blog/dave/archive/2006/01/31/2781.aspx has a more detailed example.
And now the aternative option is using your ado.net connection to your database and calling
connection.GetSchema("Tables")


and you can populate a DataTable and data bind to that in your UI

for examples see msdn here
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900