Private Sub FileListBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles FileListBox1.Click
Dim Cnn1 As New ADODB.Connection ' For I = 0 To FileListBox1.Items.Count - 1 If FileListBox1.GetSelected(I) = True Then Label3.Text = FileListBox1.Items(I) Cnn1.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Dir2.Path & "\" & FileListBox1.Items(I) & ";Jet OLEDB:Database Password=''") On Error GoTo ErrorHandler Dim rstSchema As ADODB.Recordset Const adSchemaTables As Integer = 20 rstSchema = Cnn1.OpenSchema(adSchemaTables) List1.Items.Clear() Do Until rstSchema.EOF If rstSchema.Fields("TABLE_TYPE").Value = "TABLE" Then List1.Items.Add(rstSchema.Fields("TABLE_NAME").Value) End If 'Debug.Print("Table name: " & _ 'rstSchema.Fields("TABLE_NAME").Value & vbCr & _ '"Table type: " & rstSchema.Fields("TABLE_TYPE").Value & vbCr) rstSchema.MoveNext() Loop rstSchema.Close() Cnn1.Close() rstSchema = Nothing Cnn1 = Nothing Exit Sub ErrorHandler: End If Next |