CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2000
    Posts
    2

    how to generate a list of all fields in a table (to be added to a listbox)

    how to generate a list of all fields in a table (to be added to a listbox)


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

    Re: how to generate a list of all fields in a table (to be added to a listbox)

    if you use DAO you can iterate over the Fields collection that's part of the TableDef object.


  3. #3
    Join Date
    Jan 2000
    Location
    MO, USA
    Posts
    1,506

    Re: how to generate a list of all fields in a table (to be added to a listbox)

    You could use the fields collection off the recordset object in ADO...


    Dim x as Integer
    Dim rs as ADODB.Recordset
    'get an empty recordset
    'select * from table where 1=2

    for x = 0 to rs.Fields.Count - 1
    ListBox1.AddItem rs.Fields(x).Name
    next x

    '...




    You could also use the OpenSchema method of the connection object, but im not convinced that way is any faster than the above way. It might however, be more memory efficient, I haven't tested it.

    John

    John Pirkey
    MCSD
    www.ShallowWaterSystems.com
    John Pirkey
    MCSD (VB6)
    http://www.stlvbug.org

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