Tuesday, July 7, 2009

KiXtart: Enumerate Access Database Tables with ADOX


$dbfile = "\\servername\share\folder\database.mdb"

Function ListTablesADOX($db)
Dim $Conn, $strConn, $Catalog, $Table, $Column
$strConn = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=$db"

? "Database: $db @CRLF"

$Conn = CreateObject("ADODB.Connection")
$Catalog = CreateObject("ADOX.Catalog")
$Table = CreateObject("ADOX.Table")
$Column = CreateObject("ADOX.Column")

$Conn.Open($strConn)
$Catalog.ActiveConnection = $Conn

For Each $Table In $Catalog.Tables
? "Table: " + $Table.Name
For Each $Column In $Table.Columns
? Chr(9) + "Column: " + $Column.Name
Next
Next
$Conn.Close
EndFunction

$=ListTablesADOX($dbfile)

No comments:

Post a Comment