|
-
Feb 7th, 2004, 07:36 AM
#1
Thread Starter
Lively Member
ADO - Table Collection
I'm trying to use ADO instead of DAO for accessing an MS Access Database but I can't find anything remotely similar to the DAO.TableDefs collection.
Basically, what I want to do is list all the tables within the aforementioned database in a listbox.
Any ideas?
Last edited by MileOut; Feb 8th, 2004 at 09:47 AM.
-
Feb 7th, 2004, 08:09 AM
#2
PowerPoster
-
Feb 7th, 2004, 08:13 AM
#3
PowerPoster
Heres a short example.
VB Code:
'Add a reference to Microsoft ADO Ext. 2.x
Dim objConn As New ADODB.Connection
Dim objAdox As New ADOX.Catalog
Dim TB As ADOX.Table
objConn.Open strConnectionString
objAdox.ActiveConnection = objConn
List1.Clear
For Each TB In objAdox.Tables
List1.AddItem TB.Name
Next
objConn.Close
Set objConn = Nothing
Last edited by veryjonny; Feb 9th, 2004 at 01:24 AM.
-
Feb 7th, 2004, 08:19 AM
#4
Thread Starter
Lively Member
Thank you both. That's exactly what I need.
-
Feb 7th, 2004, 08:23 AM
#5
PowerPoster
Welcome
-
Feb 8th, 2004, 09:50 AM
#6
Thread Starter
Lively Member
Further to the Tables collection, I'd now like to get the Fields collection.
I've found something through ADOX called the Columns collection which I'm guessing is the equivalent. I can't, however, seem to get a list of a table's fields into a listbox.
Any further solutions?
-
Feb 9th, 2004, 01:23 AM
#7
PowerPoster
VB Code:
Dim objConn As New ADODB.Connection
Dim objAdox As New ADOX.Catalog
Dim TB As ADOX.Table
Dim Col As ADOX.Column
objConn.Open ConnectionString
objAdox.ActiveConnection = objConn
List1.Clear
Set TB = objAdox.Tables("TableName")
For Each Col In TB.Columns
List1.AddItem Col.Name
Next
objConn.Close
Set objConn = Nothing
-
Feb 9th, 2004, 12:25 PM
#8
Addicted Member
How about listing the Access Query names and the fields that are used in each Query using ADOX ???
-
Feb 9th, 2004, 01:11 PM
#9
PowerPoster
VB Code:
Dim P As ADOX.Procedure
For Each P In objAdox.Procedures
List1.AddItem P.Name
Next
Just fingure around with this, maybe u might even get the fields involved
-
Feb 9th, 2004, 01:15 PM
#10
Fanatic Member
Here's a little more comprehensive example I made
http://www.1337geek.com/code/vb6/database/ADODB/
If wishes were fishes we'd all cast nets.
-
Feb 9th, 2004, 03:15 PM
#11
Thread Starter
Lively Member
This is all good - I can now navigate through all the tables and put all their fields into a listbox but I can't seem to dimension an ADOX.Table and then set it to the name of the table chosen in the listbox
Whenever I try (snippet):
VB Code:
Dim tbl As ADOX.Table
Set tbl = Catalog.Tables(MyListBox)
I get an error regarding not being able to find the item within the collection based on the ordinal.
-
Feb 10th, 2004, 06:18 AM
#12
PowerPoster
What are u trying?
trying to get a reference of the selected table?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|