CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 1999
    Location
    California,USA
    Posts
    7

    Listing Tables and their fields

    Hi!

    I want to get a listing of tables and their fields given a DSN.
    I will be using ADO library
    I have got a listing of tables using OpenSchema method of connection.
    But i don't know how to get a listing of field names in a table.
    Present i am doing Select * from table_name for each table
    But this will harm the performance and maytake a long time in case of large
    number of tables
    Can someone suggest a differnt method
    I want the method to be database independent

    Thanx and Regards
    Vijay



  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: Listing Tables and their fields

    this sample get column information for a specific table


    Dim cnn1 as ADODB.Connection

    Dim rstSchema as ADODB.Recordset

    set cnn1 = DataEnvironment1.Connection1

    cnn1.Open

    set rstSchema = cnn1.OpenSchema(adSchemaColumns, Array("mydb", "dbo", "mytable"))

    Dim i as Integer

    Do Until rstSchema.EOF

    for i = 0 to rstSchema.Fields.Count - 1

    List1.AddItem rstSchema.Fields(i).Name & " = " & rstSchema.Fields(i).Value

    next i

    List1.AddItem "-------------------------------"

    rstSchema.MoveNext

    Loop

    rstSchema.Close

    cnn1.Close






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