How to read TableDefs in ADO

G

Guest

Hi all,

In DAO, I could get all table information by using "for each e in
currentdb.tabledefs". How can I do similar thing in ADO?

Thanks in advance!

KS
 
B

Bob Phillips

Sub GetTables()
Dim oConn As Object
Const sFilename As String = "C:\myTest\18.xls"
Dim oCat As Object
Dim tbl As Object
Dim iRow As Long
Dim sConnString As String

sConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & sFilename & ";" & _
"Extended Properties=Excel 8.0;"

Set oConn = CreateObject("ADODB.Connection")
oConn.Open sConnString
Set oCat = CreateObject("ADOX.Catalog")
Set oCat.ActiveConnection = oConn

iRow = 1
For Each tbl In oCat.Tables
Next tbl

oConn.Close
Set oCat = Nothing

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
G

Guest

I got it! Thank you very much!

Bob Phillips said:
Sub GetTables()
Dim oConn As Object
Const sFilename As String = "C:\myTest\18.xls"
Dim oCat As Object
Dim tbl As Object
Dim iRow As Long
Dim sConnString As String

sConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & sFilename & ";" & _
"Extended Properties=Excel 8.0;"

Set oConn = CreateObject("ADODB.Connection")
oConn.Open sConnString
Set oCat = CreateObject("ADOX.Catalog")
Set oCat.ActiveConnection = oConn

iRow = 1
For Each tbl In oCat.Tables
Next tbl

oConn.Close
Set oCat = Nothing

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top