Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ado schema columns

Status
Not open for further replies.

RonRepp

Technical User
Feb 25, 2005
1,031
US
Hi all:

I'd like to add the schema columns to a listview control.

Using VBA Excel 2003.

Here's what I have:

Code:
Private Sub TV1_Click()

Select Case TV1.SelectedItem.Key
    
    
    
    Case "TABLE"
        LV1.ListItems.Clear
        LV1.ColumnHeaders.Clear
        Exit Sub
    Case "Root"
        LV1.ListItems.Clear
        LV1.ColumnHeaders.Clear
        Exit Sub
    Case "VIEW"
        LV1.ListItems.Clear
        LV1.ColumnHeaders.Clear
        Exit Sub
    Case Else
        
        LV1.ColumnHeaders.Clear
        LV1.ColumnHeaders.Add , , "Field"

        Dim Con As ADODB.Connection
        Dim FieldsRS As ADODB.Recordset
        Dim S As String
        Dim Pos As Integer
    
        Dim LI As ListItem
        LV1.View = lvwReport
        
        
        Set Con = New ADODB.Connection
        Con.ConnectionString = sCon
        Con.Open sCon
    
        Set FieldsRS = Con.OpenSchema(adSchemaColumns)
        
        LV1.ListItems.Clear
        
    While Not FieldsRS.EOF
        If FieldsRS.Fields(2) = TV1.SelectedItem.Text Then
            LV1.ListItems.Add , , FieldsRS(3)
            Debug.Print "First"
            Debug.Print FieldsRS(7)
            Debug.Print "2nd"
            Debug.Print FieldsRS(6)
        End If
        FieldsRS.MoveNext
    Wend
    Set FieldsRS = Nothing
    
End Select

Con.Close
Set Con = Nothing


End Sub

I'm finding the field names easy enough, but I'd also like to find the Type (INT,Text...), the length, and other properties.

I'll post another question for checkboxes....

thanks,

Ron Repp

If gray hair is a sign of wisdom, then I'm a genius.

My newest novel: Wooden Warriors
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top