Re: How to access MS Access from Perl?
From: luican (luican_at_yaNooSpammhoo.com)
Date: 06/03/04
- Previous message: Laura: "Re: Using underscores as well as word boundaries to demarcate a pattern"
- In reply to: Aaron W. West: "Re: How to access MS Access from Perl?"
- Next in thread: Aaron W. West: "Re: How to access MS Access from Perl?"
- Reply: Aaron W. West: "Re: How to access MS Access from Perl?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 03 Jun 2004 17:47:48 GMT
Thanks Aaron. Here's an example I modified using Win32::ODBC and an ODBC
data source to the Northwind database.
What benefits will DBI provide?
lc
use Win32::ODBC;
$db = new Win32::ODBC( "northwind" ) || die "Error connecting: " .
Win32::ODBC::Error();
if( ! $db->Sql( "SELECT CustomerID FROM customers" ) ) {
while( $db->FetchRow() ) {
%Data = $db->DataHash();
@key_entries = keys(%Data);
$Row++;
print "$Row)";
foreach $key ( keys( %Data ) )
{
print "\t'$key' = '$Data{$key}'\n";
}
}
}
else
{
print "Unable to execute query: " . $db->Error() . "\n";
}
$db->Close();
"Aaron W. West" <tallpeak@hotmail.NO.SPAM> wrote in message
news:rr2dnWe6vr0NBiDd38DK-w@speakeasy.net...
> Email to luican@yahoo.com bounces.
>
> Anyway, try DBI and DBD::ODBC. Or maybe DBD::ADO, but I've never tried it.
>
> ----------------------------------------
>
> http://cpan.org
>
> http://search.cpan.org/~jurl/DBD-ODBC-1.09/ODBC.pm
>
> ..
> Connect without DSN The ability to connect without a full DSN is
introduced
> in version 0.21.
>
> Example (using MS Access): my $DSN = 'driver=Microsoft Access Driver
> (*.mdb);dbq=\\\\cheese\\g$\\perltest.mdb'; my $dbh =
> DBI->connect("dbi:ODBC:$DSN", '','') or die "$DBI::errstr\n";
>
> The above sample uses Microsoft's UNC naming convention to point to the
> MSAccess file (\\\\cheese\\g$\\perltest.mdb). The dbq parameter tells the
> access driver which file to use for the database.
>
> ..
> ----------------------------------------
> One thing you might try is setting the default bind type to varchar as I
did
> for MS SQL Server, if you have date conversion errors. But it may not be
> relevant to MS Access:
>
> # This is needed to avoid needless sql_describe_params,
> # and errors inserting datetime values
> # It emulates old DBI 0.28 behavior:
> $dbh->{odbc_default_bind_type} = 12; # SQL_VARCHAR; #12
>
> ----------------------------------------
>
> http://search.cpan.org/~sgoeldner/DBD-ADO-2.91/lib/DBD/ADO.pm
>
> ..
> The DBD::ADO module supports ADO access on a Win32 machine.
> ..
>
>
> ----- Original Message -----
> From: "luican" <luican@yaNooSpammhoo.com>
> Newsgroups: comp.lang.perl
> Sent: Tuesday, June 01, 2004 12:07 PM
> Subject: How to access MS Access from Perl?
>
>
> Hi,
>
> Good day! I am writing some Perl script on the server side for HTML
forms
> that can create/update an MS Access database. Does anyone know of examples
> how this can be done?
>
> Your help is greatly appreciated.
>
> -lc
>
>
>
>
- Previous message: Laura: "Re: Using underscores as well as word boundaries to demarcate a pattern"
- In reply to: Aaron W. West: "Re: How to access MS Access from Perl?"
- Next in thread: Aaron W. West: "Re: How to access MS Access from Perl?"
- Reply: Aaron W. West: "Re: How to access MS Access from Perl?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|