5 Replies - 11524 Views - Last Post: 20 November 2008 - 10:06 PM Rate Topic: -----

#1 sattua  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 83
  • Joined: 20-March 08

how to select all tables from sql server with VB.net

Post icon  Posted 31 July 2008 - 09:41 PM

I need to show all tables from a database, well I dont know how, look:


Try
sqlx.Open()
Dim ver As Object
Dim sqlstring As String = "select.......Idon`t know jaja"
Dim sqlc As New SqlCommand(sqlstring, sqlx)
ver = sqlc.ExecuteNonQuery()
sqlstring = Convert.ToString(ver)
ListView1.Items.Add(sqlstring)
Catch ex As Exception
MsgBox("No tables Found")
End Try

I need a query or something to list all tables... HOW???

Is This A Good Question/Topic? 0
  • +

Replies To: how to select all tables from sql server with VB.net

#2 DeCompile  Icon User is offline

  • D.I.C Regular

Reputation: 19
  • View blog
  • Posts: 301
  • Joined: 20-July 08

Re: how to select all tables from sql server with VB.net

Posted 31 July 2008 - 09:51 PM

Are you trying to list all the tables that are included in that database or are you attempting to view all the data from the tables?

They are actually two different things:

The first will give you a list of all the databases / tables that are contained within the SQL server.

The other will give all the data contained within the database/table you are querying.
Was This Post Helpful? 0
  • +
  • -

#3 sattua  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 83
  • Joined: 20-March 08

Re: how to select all tables from sql server with VB.net

Posted 31 July 2008 - 09:56 PM

nono, I have to show all the tables of a database...

maybe the code that I showed you, it is not completely well, but the idea is that to show all the tables



thanks......
Was This Post Helpful? 0
  • +
  • -

#4 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1641
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: how to select all tables from sql server with VB.net

Posted 31 July 2008 - 10:16 PM

You have two options, you can use

SELECT * FROM sysobjects WHERE type = 'U' 



Or for a more ANSI orientated result you can use

SELECT * FROM INFORMATION_SCHEMA.TABLES


Was This Post Helpful? 0
  • +
  • -

#5 layaroo  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 11-January 08

Re: how to select all tables from sql server with VB.net

Posted 20 November 2008 - 01:33 PM

View PostDeCompile, on 31 Jul, 2008 - 08:51 PM, said:

Are you trying to list all the tables that are included in that database or are you attempting to view all the data from the tables?

They are actually two different things:

The first will give you a list of all the databases / tables that are contained within the SQL server.

The other will give all the data contained within the database/table you are querying.


so how to get the list of database??
I am trying to get it and it is still couldn't find any information found on web sites yet.
Was This Post Helpful? 0
  • +
  • -

#6 magicmonkey  Icon User is offline

  • D.I.C Regular

Reputation: 106
  • View blog
  • Posts: 484
  • Joined: 12-September 08

Re: how to select all tables from sql server with VB.net

Posted 20 November 2008 - 10:06 PM

select * from sys.databases



Depending what you want to do you can also use the SQL SMO .NET objects to manage a SQL Server.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1