1 Previous Next 

Access (OleDB): List Database Tables


Use the oledb connections GetOleDbSchemaTable method to list the tables in an access database.
Module Module1
    Sub Main()
        Dim strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"
        strConn &= "Data Source = C:\Test1\Nwind.mdb;"
        Dim dtTableNames As DataTable
        Using conn As New OleDb.OleDbConnection(strConn)
            conn.Open()
            dtTableNames = conn.GetOleDbSchemaTable(OleDb.OleDbSchemaGuid.Tables, _
                New Object() {NothingNothingNothing"TABLE"})
        End Using
        Dim dr As DataRow
        For Each dr In dtTableNames.Rows
            Console.WriteLine(dr.Item("TABLE_NAME"))
        Next
        Console.ReadLine()
    End Sub
End Module



1 Previous Next