- Private Sub Command1_Click()
-
- Dim MaConn As ADODB.Connection, rstTable As ADODB.Recordset
- Dim rstEnfant As ADODB.Recordset
-
- 'création de la connexion
- Set MaConn = New ADODB.Connection
- MaConn.Provider = "Microsoft.Jet.OLEDB.4.0;"
- MaConn.Open Text1.Text
-
- 'création du recordset contenant la structure des tables
- Set rstTable = New ADODB.Recordset
- Set rstTable = MaConn.OpenSchema(adSchemaTables)
-
- 'on ouvre le .txt de destination
- Open "c:\structure.txt" For Output As #1
-
- 'Parcours de la collection des tables
- Do While Not rstTable.EOF
-
- NomTable = rstTable!Table_Name
-
- 'élimine les tables systèmes et les Vues
- If InStr(1, NomTable, "MSYS", vbTextCompare) <> 1 And rstTable!Table_Type <> "VIEW" Then
-
- 'on écrit le nom de la table
- Print #1, NomTable
-
- 'on ouvre le schéma pr obtenir les champs
- Set rstEnfant = New ADODB.Recordset
- Set rstEnfant = MaConn.OpenSchema(adSchemaColumns, Array(Empty, Empty, NomTable, Empty))
-
- 'on parcours les champs
- Do While Not rstEnfant.EOF
-
- 'on écri les champs précédés d'un "-"
- Print #1, " - " & rstEnfant!COLUMN_NAME
- 'champs suivant
- rstEnfant.MoveNext
-
- Loop
- rstEnfant.Close
- Set rstEnfant = Nothing
- 'on saute une ligne pour changer de table
- Print #1, vbCr
- End If
- 'table suivante
- rstTable.MoveNext
-
- Loop
-
- Close #1
-
- End Sub
Private Sub Command1_Click()
Dim MaConn As ADODB.Connection, rstTable As ADODB.Recordset
Dim rstEnfant As ADODB.Recordset
'création de la connexion
Set MaConn = New ADODB.Connection
MaConn.Provider = "Microsoft.Jet.OLEDB.4.0;"
MaConn.Open Text1.Text
'création du recordset contenant la structure des tables
Set rstTable = New ADODB.Recordset
Set rstTable = MaConn.OpenSchema(adSchemaTables)
'on ouvre le .txt de destination
Open "c:\structure.txt" For Output As #1
'Parcours de la collection des tables
Do While Not rstTable.EOF
NomTable = rstTable!Table_Name
'élimine les tables systèmes et les Vues
If InStr(1, NomTable, "MSYS", vbTextCompare) <> 1 And rstTable!Table_Type <> "VIEW" Then
'on écrit le nom de la table
Print #1, NomTable
'on ouvre le schéma pr obtenir les champs
Set rstEnfant = New ADODB.Recordset
Set rstEnfant = MaConn.OpenSchema(adSchemaColumns, Array(Empty, Empty, NomTable, Empty))
'on parcours les champs
Do While Not rstEnfant.EOF
'on écri les champs précédés d'un "-"
Print #1, " - " & rstEnfant!COLUMN_NAME
'champs suivant
rstEnfant.MoveNext
Loop
rstEnfant.Close
Set rstEnfant = Nothing
'on saute une ligne pour changer de table
Print #1, vbCr
End If
'table suivante
rstTable.MoveNext
Loop
Close #1
End Sub