Answered Get SQL Datatable Names using VB.Net

  • Friday, July 13, 2012 1:57 PM
     
     

    Hello,

    I am trying use VB.Net 2010 express to get all the Table names from my data base. Below is my code:

    Dim

    conStr As String = ("Server=(local)\sqlexpress; DataBase= " & ParmDataBase & "; Integrated Security=SSPI")

    Dim DBCon As New SqlConnection(conStr)

    strSQL =

    "SELECT * FROM INFORMATION_SCHEMA.tables"

    Dim da As SqlDataAdapter = New SqlDataAdapter(strSQL, DBCon)

    Dim ds As New DataSet()

    da.Fill(ds)

    Dim MyTableCount As Integer = ds.Tables.Count

    For Each table As DataTable In ds.Tables

    ComboBox1.Items.Add(table.TableName)

    Next

    The problem is that that my dataset (ds) is not filled with my database information. For example, I have 4 tables but the ds.Tables.Count returns 1 and the only table name I get is "Table". 

    wharding

All Replies