S
Sam Hobbs
As best as I understand from the documentation and these newsgroups, the
code below should work. However I am getting an empty recordset (both BOF
and EOF are true). I am just writing out a table's field information using
OpenSchema.
If this is not the correct newsgroup for this, then you can just tell me
where to go.
Sub TestShowTable()
Open "TableSchema.txt" For Output As #1
ShowTable CurrentProject.Connection, "Table1"
Close #1
End Sub
Public Sub ShowTable(Connection, TableName)
Dim rstSchema As New ADODB.Recordset
Dim Criteria(3) As Variant
Criteria(0) = Empty ' TABLE_CATALOG
Criteria(1) = Empty ' TABLE_SCHEMA (owner)
Criteria(2) = TableName ' TABLE_NAME
Criteria(3) = Empty ' COLUMN_NAME
Set rstSchema = Connection.OpenSchema(adSchemaColumns, Criteria)
If rstSchema.RecordCount <= 0 Then
MsgBox "No table or no fields in table"
End If
Do While Not rstSchema.EOF
Record = rstSchema!TABLE_NAME
Record = Record & vbTab & rstSchema!ORDINAL_POSITION
Record = Record & vbTab & rstSchema!COLUMN_NAME
Record = Record & vbTab & rstSchema!DATA_TYPE
Record = Record & vbTab & rstSchema!CHARACTER_MAXIMUM_LENGTH
Record = Record & vbTab & rstSchema!NUMERIC_PRECISION
Print #1, Record
rstSchema.MoveNext
Loop
rstSchema.Close
End Sub
code below should work. However I am getting an empty recordset (both BOF
and EOF are true). I am just writing out a table's field information using
OpenSchema.
If this is not the correct newsgroup for this, then you can just tell me
where to go.
Sub TestShowTable()
Open "TableSchema.txt" For Output As #1
ShowTable CurrentProject.Connection, "Table1"
Close #1
End Sub
Public Sub ShowTable(Connection, TableName)
Dim rstSchema As New ADODB.Recordset
Dim Criteria(3) As Variant
Criteria(0) = Empty ' TABLE_CATALOG
Criteria(1) = Empty ' TABLE_SCHEMA (owner)
Criteria(2) = TableName ' TABLE_NAME
Criteria(3) = Empty ' COLUMN_NAME
Set rstSchema = Connection.OpenSchema(adSchemaColumns, Criteria)
If rstSchema.RecordCount <= 0 Then
MsgBox "No table or no fields in table"
End If
Do While Not rstSchema.EOF
Record = rstSchema!TABLE_NAME
Record = Record & vbTab & rstSchema!ORDINAL_POSITION
Record = Record & vbTab & rstSchema!COLUMN_NAME
Record = Record & vbTab & rstSchema!DATA_TYPE
Record = Record & vbTab & rstSchema!CHARACTER_MAXIMUM_LENGTH
Record = Record & vbTab & rstSchema!NUMERIC_PRECISION
Print #1, Record
rstSchema.MoveNext
Loop
rstSchema.Close
End Sub