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

    Filling a combo with table names in an mdb through ADO

    Hi.
    I'm trying to make a program that shows a user a list of available tables in a database he selects, either through SQL ADO or Jet.
    through jet i can't find a way for the user to select a table.
    i don't know how to do something similer to "Select * from sysobjects" in SQL.
    how do i do that?
    it should be like the combo you get when building a connection string in Adodc when chooseing a table to connect to under thew "adcmdTable" catagory.
    thx.


    ---------



    Life is like an analogy.

  2. #2
    Join Date
    Apr 1999
    Location
    Brooklyn, NY USA
    Posts
    171

    Re: Filling a combo with table names in an mdb through ADO

    Use this. It's very similar with ADO or DAO:
    Place Combo1, Command1 on Form1, add reference to DAO or ADO object library and copy this code. Replace DBName with appropriate.

    option Explicit
    private db as Database

    private Sub Command1_Click()
    Dim intIndex as Integer
    for intIndex = 0 to db.TableDefs.Count - 1
    Combo1.AddItem db.TableDefs(intIndex).Name
    next intIndex
    End Sub

    private Sub Form_Load()
    set db = OpenDatabase("DBName")
    End Sub



    Don't forget to close all open objects in unload event.
    HTH
    Vlad



  3. #3
    Guest

    Re: Filling a combo with table names in an mdb through ADO

    the "as database" does not appear in the ado reference.
    only in the dao one.



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

    Re: Filling a combo with table names in an mdb through ADO

    There is no tabledefs object in ADO!


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

    Re: Filling a combo with table names in an mdb through ADO

    you need to use the OpenSchema method in ADO

    Dim cnn1 as ADODB.Connection

    Dim rstSchema as ADODB.Recordset

    set cnn1 = DataEnvironment1.Connection1

    cnn1.Open strCnn

    set rstSchema = cnn1.OpenSchema(adSchemaTables)

    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