Results 1 to 13 of 13

Thread: [RESOLVED] View Tables in a Database

  1. #1

    Thread Starter
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Resolved [RESOLVED] View Tables in a Database

    After opening my connection, I want to view the tables found in my database and display them on screen. Can anybody please help me do that?

    Thanx
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

  2. #2
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: View Tables in a Database

    If your using ADO, you can use 'Schema'. A search will yeild examples.

  3. #3

    Thread Starter
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: View Tables in a Database

    Yes I'm using ADO. is it the openschema function in the connection string? How do i do it?
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

  4. #4

  5. #5

    Thread Starter
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: View Tables in a Database

    well what i actually want to do is to view the tables found in my Access, SQL Server Database and also the worksheets in Microsoft excel
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

  6. #6

    Thread Starter
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: View Tables in a Database

    I'm going to view these tables in a treeview then if a user clicks on a table, the fields will be displayed in a listbox
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

  7. #7
    Fanatic Member noielen's Avatar
    Join Date
    Nov 2005
    Location
    Cebu, Phil.
    Posts
    680

    Re: View Tables in a Database

    noister
    <advertising link removed by moderator>

  8. #8

    Thread Starter
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: View Tables in a Database

    i've seen the link, ive tried it but unfortunately, its not working
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

  9. #9
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: View Tables in a Database

    Set references to ADO and also ADO Ext. ... and try this sample:
    VB Code:
    1. Private Sub Command1_Click()
    2. '============================
    3. Dim tbl As ADOX.Table
    4. Dim cat As ADOX.Catalog
    5. Dim cnn As ADODB.Connection
    6. Dim i%
    7.  
    8.     Set cnn = New ADODB.Connection
    9.     cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    10.              "Data Source=" & App.Path & "\biblio.mdb;"
    11.    
    12.     Set cat = New ADOX.Catalog
    13.     Set cat.ActiveConnection = cnn
    14.    
    15.     For Each tbl In cat.Tables
    16.         Combo1.AddItem que.Name
    17.     Next tbl
    18.    
    19.     cnn.Close
    20.    
    21.     Set cat = Nothing
    22.     Set cnn = Nothing
    23.  
    24. End Sub

  10. #10

    Thread Starter
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: View Tables in a Database

    thankx Rhino. First, it didn't work due to the que.Name

    what i did is i just changed que to tbl which is defined as a table in adox. only one thing, I have one excel worksheet in my excel file called was2. when i run that code, it returnce two values, was2$(which is the expected output) and was2$_. is this a normal scenario in adox or theres is something missing in the code.

    my first approach for this is to filter the returned values if the last character is an (_). if it is, i wont display it but if not, i will.

    is there any other better option for this?
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

  11. #11

    Thread Starter
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: View Tables in a Database

    well i just filter the tablenames by looking for the $ sign at the end of the value returned. if the last character of the value is $ then it is one of the worksheets in excel and it will display it. ir not it wont, thanks Rhino for the help
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

  12. #12

  13. #13

    Thread Starter
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: [RESOLVED] View Tables in a Database

    am i on the right track on my solution above, or theres another way of doing it?
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

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