Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello guys,

Can you please help me?

How can I show all the tables of my database in VB.NET?

my Codes are here:

VB
Public Sub PopulateTables()

Dim strQUERY as string="SHOW TABLES FROM [database]"

Dim DReader As New DataClassReader
DReader.strSELECTSQL = strQUERY
DReader.ReadData()
datagrid1.Rows.Clear()
Dim a As Integer = 0

Do While DReader.DataReader.Read
datagrid1.Rows.Add()
With DReader.DataReader.Read
datagrid1.Item(1,a).Value = .Item("")
End With
Loop
DReader.DataReader.Close()
End Sub
Posted
Updated 17-Nov-10 22:48pm
v2
Comments
Dalek Dave 18-Nov-10 4:48am    
Edited for Grammar and Spelling.
Simon_Whale 18-Nov-10 6:26am    
does anything comeback from executing the command on the mysal database?

1 solution

Try this query:
This can be achieved using system table sys.tables.
SQL
USE YourDBName
GO
SELECT *
FROM sys.Tables
GO

This will return all the tables in the database which user have created

OR
SQL
--To view tables in the current schema
SELECT OBJECT_NAME FROM USER_OBJECTS WHERE OBJECT_TYPE = 'TABLE'
--To view all the tables that you have access
SELECT OBJECT_NAME FROM ALL_OBJECTS WHERE OBJECT_TYPE = 'TABLE'
--To view all the tables in the database
SELECT OBJECT_NAME FROM DBA_OBJECTS WHERE OBJECT_TYPE = 'TABLE'

--You may use user_tables instead of user_objects.
 
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