CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Tables Count

  1. #1
    Join Date
    Aug 2000
    Posts
    37

    Tables Count

    hi,
    Is there any Tables Collection in ADO?
    i need to count the tables in my database and listing them, so my users can edit any table without me to write special procedure to do that.
    10x.

    Daniel Prinz

  2. #2
    Join Date
    Aug 2000
    Location
    Dublin
    Posts
    20

    Re: Tables Count

    Yep,

    There are a couple of ways to do this.

    1. Include a reference to MSADOX.dll (Microsoft ADO Ext) and use the Catalog class
    2. In ADO Connection class, there is a function OpenSchema where you can specify the schema type to open and this is returned in an ADO recordset. Check out the help on this for the column names that store the table details.

    Thanx
    Andrew


  3. #3
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Tables Count

    Sub ListTables()

    Dim cat As New ADOX.Catalog
    Dim tbl As ADOX.Table

    'References : Microsoft ADO Ext 2.1 or DDL and Security

    ' Open the catalog
    cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=c:\nwind.mdb;"

    ' Loop through the tables in the database and print their name
    For Each tbl In cat.Tables
    If tbl.Type <> "VIEW" Then List1.AddItem tbl.Name
    'not to see system tables If Left$(tbl.Name, 4) <> "MSys" Then List1.AddItem tbl.Name

    Next

    End Sub

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

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

Featured