|
-
Jul 11th, 2000, 06:31 PM
#1
I was wondering if there is a way to get the names of tables in a database using an SQL statement. I am trying to keep it database independent so it can be used with any ODBC data source. If there is not a way to do this for all database, I would like to see an example using ADO and MS Access.
Thanks in advance,
-
Jul 11th, 2000, 06:44 PM
#2
Fanatic Member
************************************************************
Dim adoConn as ADODB.Connection
Dim adoRsFields As ADODB.recordset
Dim sConn as String
Dim sCurrentTable as String
Dim sNewTable as String
Set adoConn = New ADODB.Connection
sConn = "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=c:\yourdb.mdb;
adoConn.open sConn
Set adoRsFields = adoConn.OpenSchema(adSchemaColumns)
sCurrentTable = ""
sNewTable = ""
Do Until adoRsFields.EOF
sCurrentTable = adoRsFields!TABLE_NAME
If (sCurrentTable <> sNewTable) Then
sNewTable = adoRsFields!TABLE_NAME
Debug.Print "Current Table: " & RsFields!TABLE_NAME
End If
Debug.Print " Field: " & adoRsFields!COLUMN_NAME
adoRsFields.MoveNext
Loop
************************************************************
The above code was taken from Beginning VB6 Databases by John Connell from WROX.
Psyrus
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
|