Results 1 to 4 of 4

Thread: ADO - Listing Tables and Fields

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    NY, USA.
    Posts
    240
    Hi,
    I have two questions:
    (1) How do you load/ist all the Tables from a Database into a combo box or a list box ??

    (2) How do load/list all the Fields from a Table into a combo box or a list box ??


    Thanks
    Omar
    [email protected]
    http://omar.caribwalk.com
    To God Be The Glory

    I see Tech People ...

  2. #2
    New Member
    Join Date
    Apr 2000
    Posts
    6
    Hi,
    Collecting all tables and putting in to a listbox
    *************************************************

    very good question, i will idea to get the tables
    from ORACLE, you try it.

    1. Create a ADODB instance
    (Project -> Reference
    Microsoft ActiveX Data Objects )
    2. dim conn as new adodb.connection
    dim res as new adodb.recordset

    3. Establish a connection through connectionstring

    4. open a recordset by using sql statement using
    a data dictionary USER_TAB_COLUMNS

    5. create a listbox
    6. for i = 0 to recordset object.recordcount-1
    listbox1.additem recordset object(i)
    next i

    try this , surely this will work,
    bye,
    reply soon, my addresss [email protected] (anand)

  3. #3
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    List all tables:
    Code:
        'references:
        'ActiveX Data Objects 2.x
        'ADO 2.x for DDL and security
        
        Dim tbl As ADOX.Table
        Dim cn As ADODB.Connection
        
        Dim ax As ADOX.Catalog
        
        Set cn = New ADODB.Connection
        
        'connect
        cn.Open "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=Nwind.mdb"
        
        Set ax = New ADOX.Catalog
        
        ax.ActiveConnection = cn
        
        'loop thru tables
        For Each tbl In ax.Tables
            Debug.Print tbl.Name & " " & tbl.Type
        Next tbl
        
        'close connection
        cn.Close
        Set cn = Nothing
    List all fields in a table:
    Code:
    'uses ADO 2.5
    '     ADO 2.5 for DDL and security
    
        Dim cn As Connection
        Dim ax As Catalog
        Dim tbl As Table
        Dim fld As Field
        Dim cl As Column
        Set cn = New Connection
        
        'open connection to db
        cn.Open "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=NWind.mdb"
        
        Set ax = New Catalog
        ax.ActiveConnection = cn
        
        'get table reference
        Set tbl = ax.Tables("Employees")
        
        'list all fields
        For Each cl In tbl.Columns
            Debug.Print cl.Name
        Next cl
        
        'cleanup
        Set cl = Nothing
        Set ax = Nothing
        
        cn.Close
        Set cn = Nothing

  4. #4
    New Member
    Join Date
    Apr 2000
    Posts
    6
    THANKS FOR REPLYING, YOU DID'NT MENTIONED ABOUT ORACLE
    TABLE,

    HOW TO DOWNLOAD A FILE FROM THE WEB SERVER (THROUGH
    VB CODING).


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