Take the following steps:

#################################
1) Install Modules DBI and ODBC:

<screen snapshot>

Microsoft Windows 2000 [Versão 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.

D:\Perl>ppm

PPM> install DBI

Install package 'DBI?' (y/N): y

Installing package 'DBI'...
Bytes transferred: 368671
Installing D:\Perl\site\lib\auto\DBI\dbd_xsh.h
Installing D:\Perl\site\lib\auto\DBI\DBI.bs
....etc...
Installing D:\Perl\bin\dbish
Installing D:\Perl\bin\dbish.bat
Writing D:\Perl\site\lib\auto\DBI\.packlist

PPM> install DBD-ODBC

Install package 'DBD-ODBC?' (y/N): Y

Installing package 'DBD-ODBC'...
Bytes transferred: 35966
Installing D:\Perl\site\lib\auto\DBD\ODBC\ODBC.bs
Installing D:\Perl\site\lib\auto\DBD\ODBC\ODBC.dll
Installing D:\Perl\site\lib\auto\DBD\ODBC\ODBC.exp
Installing D:\Perl\site\lib\auto\DBD\ODBC\ODBC.lib
Installing D:\Perl\html\site\lib\DBD\ODBC.html
Installing D:\Perl\site\lib\DBD\ODBC.pm
Writing D:\Perl\site\lib\auto\DBD\ODBC\.packlist
PPM> QUIT
Quit!

D:\Perl>

</screen snapshot>


############################################################
2) Configure a System DSN for the file to be accessed via ODBC DataSource
(Control Panel / Administrative Tools), like this:

name = Agenda
drive = MS Access (*.mdb)
file = C:\Agenda.mdb   (drive:\fullpath\filename.mdb)


#########################
3) Try this code example:

<code>

use DBI;

$dbh = DBI->connect( "dbi:ODBC:Agenda", "", "",
       {RaiseError => 1, PrintError => 1, AutoCommit => 1} ) or
       die "Unable to connect: " . $DBI::errstr . "\n";

$sel = $dbh->prepare( "select name, phone, city, country from phonebook
where city = ? and country = ? order by name" );
@col = ( 'Sao Paulo', 'Brazil' );
$sel->execute( @col );

while( @col = $sel->fetchrow_array ){
 $name = $col[0];
 $phone = $col[1];
 $city = $col[2];
 $country = $col[3];
 printf "\n\n\rName___: \t%s \n\rPhone__: \t%s \n\rCity___: \t%s
\n\rCountry: \t%s",
               $name, $phone, $city, $country;
}

$sel->finish;
$dbh->disconnect;


</code>

The SQL statement applied in "$dbh->prepare( ... )" may be a select, insert,
update, delete.

I hope it helps you.

Josimar Nunes de Oliveira
[EMAIL PROTECTED]





----- Original Message -----
From: "Cleiton L. Siqueira" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, October 16, 2002 6:02 PM
Subject: Microsoft Access Question


> Dear,
>
> I need to retrieve data from Microsoft Access database and put them in a
PostgreSQL database.
> I got to access PostgreSQL normally, but I can't open a Microsoft Access
database using perl.
> Someone knows how can I do it?
>
> Thanks!
>
>
> Cleiton L. Siqueira
> Colégio Monjolo
> [EMAIL PROTECTED]
> (0xx45) 520-1915
>
> Esta mensagem foi enviada pelo sistema MONJOLO WEBMAIL
>
> http://www.colegiomonjolo.com.br
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to