Get table names from database

ManicCW

Well-known member
Joined
Jul 21, 2005
Messages
428
Location
Mostar
Programming Experience
Beginner
I need to get table names using datareader. Now I know how to do that using INFORMATION_SCHEMA query but this retrives some system tables. How can I retrive only user tables?
 
Hi ManicCW,
You may want to try this out...


Dim
index As Integer
SqlConnection = New SqlConnection("server=Localhost;Database=NorthWind;uid=sa")SqlConnection.Open()
SqlCommand = New SqlCommand("Select Name FROM dbo.sysobjects WHERE xtype = 'U'", SqlConnection)

SqlCommand.CommandType = CommandType.Text

SqlDataReader = SqlCommand.ExecuteReader()
While SqlDataReader.Read

ComboBox1.Items.Add(SqlDataReader.Item(0))

End While


SqlDataReader.Close()

SqlConnection.
Close()



Regards,
Vishal Adsool

 
no its impossible to retrieve tablenames from datareader object. datareader retrieves data only in forward mode and that too in read only format. its sole pupose is to retrieve the data from the data source and not the tablenames.
 
Back
Top