|
-
Mar 26th, 2000, 08:07 PM
#1
Thread Starter
New Member
Hi,
Can anyone please tell me how to get my DB table names into a recordset. I'm using the following code to create a recordset:
Dim rs As adodb.Recordset
Set rs = New adodb.Recordset
rs.Open SQL, conn, adOpenKeyset, adLockOptimistic
This works fine and I can get all the info that I need from the DB, but how do I get the relevant table names aswell??
Any suggestions or help would be greatly appreciated!
cheers,
shovels
-
Mar 26th, 2000, 10:17 PM
#2
New Member
use "openschema" method.... just like this..cHeErs 
Set adoRsFields = adoConnection.OpenSchema(adSchemaColumns)
Example:
Private Sub cmdSchema_Click()
Dim adoConnection As ADODB.Connection
Dim adoRsFields As ADODB.Recordset
Dim sConnection As String
Dim sCurrentTable As String
Dim sNewTable As String
Set adoConnection = New ADODB.Connection
sConnection = "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=c:\BegDB\Biblio.mdb"
adoConnection.Open sConnection
Set adoRsFields = adoConnection.OpenSchema(adSchemaColumns)
sCurrentTable = ""
sNewTable = ""
Do Until adoRsFields.EOF
sCurrentTable = adoRsFields!TABLE_NAME
If (sCurrentTable <> sNewTable) Then
sNewTable = adoRsFields!TABLE_NAME
Debug.Print "Current Table: " & adoRsFields!TABLE_NAME
End If
Debug.Print " Field: " & adoRsFields!COLUMN_NAME
adoRsFields.MoveNext
Loop
adoRsFields.Close
Set adoRsFields = Nothing
adoConnection.Close
Set adoConnection = Nothing
End Sub
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
|