Results 1 to 5 of 5

Thread: Tables in DB

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026

    Tables in DB

    How do I find out how many tables there are in a database using SQL or ADO????

    Thanx,
    Squirrelly1

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    This will list them, will that help?
    VB Code:
    1. Private Sub GetDbTables()
    2.  
    3.    Dim Cnxn As ADODB.Connection
    4.    Dim rstSchema As ADODB.Recordset
    5.    Dim strCnxn As String
    6.      
    7.    Set Cnxn = New ADODB.Connection
    8.    strCnxn = "Provider=sqloledb;Data Source=MyServer;Initial Catalog=Pubs;User Id=sa;Password=; "
    9.    Cnxn.Open strCnxn
    10.      
    11.    Set rstSchema = Cnxn.OpenSchema(adSchemaTables)
    12.    
    13.    Do Until rstSchema.EOF
    14.       List1.AddItem "Table name: " & rstSchema!TABLE_NAME & vbCr & "Table type: " & rstSchema!TABLE_TYPE & vbCr
    15.       rstSchema.MoveNext
    16.    Loop
    17.    
    18.    ' clean up
    19.    rstSchema.Close
    20.    Cnxn.Close
    21.    Set rstSchema = Nothing
    22.    Set Cnxn = Nothing
    23.    
    24. End Sub

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026

    criteria

    Is there any way to show just the tables where the table type is "TABLE". All of the other tables are irrelavent...


    thanx again,
    Squirrelly1

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026

    actually...

    actually, I need to be able to loop through them all and pull data from them based on a criteria string in sql...

    This is some cool code, but now that I think of it, it won't really help me.


    Do you know how to do what I need?

    squirrelly1

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Well, I never had the need to do this before, but I should work.

    Modify the code I gave you and use rstSchema!TABLE_TYPE = 'Whatever'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width