Article ID: 185979
Article Last Modified on 7/13/2004
Dim cn As ADODB.Connection
Dim rsSchema As ADODB.Recordset
Dim fld As ADODB.Field
Dim rCriteria As Variant
Set cn = New ADODB.Connection
With cn
.Provider = "MSDASQL" 'default Provider=MSDASQL
.CursorLocation = adUseServer
.ConnectionString = "driver={SQL Server};server=(local);" & _
"uid=UserName;pwd=StrongPassword;database=pubs"
.Open
End With
'Pass in the table name to retrieve index info. The other
'array parameters may be defined as follows:
' TABLE_CATALOG (first parameter)
' TABLE_SCHEMA (second)
' INDEX_NAME (third)
' TYPE (fourth)
' TABLE_NAME (fifth, e.g. "employee")
rCriteria = Array(Empty, Empty, Empty, Empty, "employee")
Set rsSchema = cn.OpenSchema(adSchemaIndexes, rCriteria)
Debug.Print "Recordcount: " & rsSchema.RecordCount
While Not rsSchema.EOF
Debug.Print "==================================================="
For Each fld In rsSchema.Fields
Debug.Print fld.Name
Debug.Print fld.Value
Debug.Print "------------------------------------------------"
Next
rsSchema.MoveNext
Wend
rsSchema.Close
Set rsSchema = Nothing
cn.Close
Set cn = Nothing
Set fld = Nothing
Keywords: kbhowto kbdatabase KB185979