Win32::OLE ADO Table Field names
am 23.12.2007 19:15:38 von goldtechHi,
Given code below, I can get tables and run SQL on an ms-access db -
this works well. But, I want to get the field names per each column
of a table. I'm sure there's an ADO way of doing it. Help appreciated.
Thanks.
Question: How do I get the field names of each column of a table?
#!/usr/bin/perl
# use strict;
use Win32::OLE();
$Win32::OLE::Warn=2;
my $conn = Win32::OLE->new("ADODB.Connection");
my $db = 'C:\Folder4\usa.mdb';
$conn->Open('Provider = Microsoft.Jet.OLEDB.4.0; Data Source='.$db);
my $rs= $conn->OpenSchema(20);
$rs->MoveFirst();
while(!$rs->{EOF}){
my $tn= $rs->Fields(2)->Value;
if (grep /^$tn$/i, 'States') {
my $rowcount = $conn->Execute("SELECT COUNT(*) AS ROW_COUNT
FROM " .$tn.'"');
print "$tn : ".$rowcount->Fields('ROW_COUNT')->Value."\n";
}
$rs->MoveNext;
}
__END__
states : 51
DC included.