Re: Getting all names in mdb



Hi. Long time to see you :-).

----- Original Message -----
Subject: Getting all names in mdb
Date: Fri, 7 Dec 2007 11:19:05 +0900
From: 田口 浩 <h-taguchi@xxxxxxxxxxx>
To: <dbi-users@xxxxxxxx>


Hello,

I'm using .mdb file with DBI/DBD::ODBC.

my $dbh = DBI->connect("dbi:ODBC:test", "", "",
{RaiseError => 1, AutoCommit => 0, LongReadLen => 409600})
or die "$DBI::errstr";

Anyone will teach me how to get all names of tables
(in test.mdb)?
If you want to use ODBC, you can get them from "MSysObjects" table.
But probably you should set reading previledges for that mdb files.

cf. Sorry these are in Japanese
http://www.accessclub.jp/bbs6/0003/das426.html
http://homepage1.nifty.com/kojama/works/rdbms/jet/dbinfo.html#term04
http://www.nihon-eng.co.jp/c-break/technote/tomcat/TCAT41_DB.htm

# I've set them with Security Wizard

ex.
use strict;
use DBI;
my $sDsn = 'driver=Microsoft Access Driver (*.mdb);dbq=c:\test.mdb;'.
'SystemDB=c:\security.mdw';
my $hDb = DBI->connect('dbi:ODBC:'. $sDsn, 'dbdtest', 'dbdtest',
{RaiseError=>1, AutoCommit=> 1});
my $hSt = $hDb->prepare(
q{SELECT name FROM MSysObjects WHERE type=1 AND name NOT LIKE 'MSys%'}
);
$hSt->execute();
while(my $raD = $hSt->fetchrow_arrayref())
{
print join("\t", @$raD) . "\n";
}
$hSt->finish();
$hDb->disconnect();

.