VB6 / Access / Schema

  • Thread starter Thread starter RobertLees
  • Start date Start date
R

RobertLees

Guest
Hi

I would like to add to my VB6 app the ability to build an array of what tables are in my Access database, and the fields that are in each of those tables.

I am working with this database using ADODB, but it doesn't give properties like Tables and Fields, for example.

I am happy to open this database some other way, grab this info, close that connection, and proceed using ADODB.

What do you think

Robert
 
This example shows how to list database objects from within access (not what you asked I know) but it may help.

Dave
 

Attachments

You could try using the newer ADO extensions (ADOX) in addition to normal ADO.
Try adding a reference to Microsoft ADO ext. 2.8 for DDL and Security (2.8 is my current version, yours might not be the same...) and run the following,

Dim cat As ADOX.Catalog
Dim tbl As Table
Dim ColCount As Integer
Dim ColLoop As Integer

Set cat = New ADOX.Catalog
cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\mydb.mdb"

For Each tbl In cat.Tables

Debug.Print tbl.Name

ColCount = tbl.Columns.Count

For ColLoop = 1 To (ColCount - 1)
Debug.Print tbl.Columns(ColLoop).Name
Next ColLoop

Next tbl

Set cat = Nothing

a bit raw, but it should do the job if you replace the 'debugs' with array assignments.
 

Users who are viewing this thread

Back
Top Bottom