- 论坛徽章:
- 0
|
原帖由 gingerhot 于 2009-8-4 16:50 发表 ![]()
想把a.txt中的内容写进access数据库里,比如a.txt只有一列多行数据如下:
xxx有限公司
sss水泥厂
用 ...
贴个以前写的闷门闷骚程序出来吧
use strict;
use warnings;
use Win32::OLE;
my $conn = 'Provider=Microsoft.Jet.OLEDB.4.0;' . 'Data Source=C:\Scripts\pool.mdb';
my $pool_db = Win32::OLE->new( "ADODB.Connection" ) or die $!;
$pool_db->Open( $conn );
my $rs = $pool_db->Execute( 'SELECT * FROM SwimmingPool' ) or die join "\n", map { $pool_db->Errors->Item( $_ )->Description } ( 0 .. $pool_db->Errors->Count - 1 );
while( !$rs->EOF ){
print "Name: ", $rs->Fields('Customer')->Value(), "\n";
if( $rs->Fields('Slope')->Value() ){
print " Volume of Water: ", $rs->Fields('Length')->Value() * $rs->Fields('Width')->Value() * ( ( $rs->Fields('SStart')->Value() + $rs->Fields('SEnd')->Value() ) / 2 ) * 1000, "\n\n";
} else {
print " Volume of Water: ", $rs->Fields('Length')->Value() * $rs->Fields('Width')->Value() * $rs->Fields('Depth')->Value() * 1000, "\n\n";
}
$rs->MoveNext();
}
$rs->close();
$pool_db->close(); |
|
|