(the simplest question of the century ?) Simple access to ... ACCESS!

M

Milca

Hi all,

I'm a (or "one more") newcomer in Perl, and ask for very basic help.

Despite some time spent to read all this forum and some CPAN docs, I've
not found a simple explanation of my request however simple.

I'd like to access - read only is sufficient for the beginning - to an
MS ACCESS database from perls scripts. I'm on Win 2K.I'd like to make
simple SQL or SQL-like queries (is that a pure dream ?) :seeing my
tables, seeing the data of each table, bing able to select elementary
data in tables, and even not necessarily with joining them. ... Truly a
"basic access to ACCESS" !

.... And (to be complete) I would like to use these perl scripts from
"unix style" command lines inside a "cygnus" bash shell ... But this
detail is probably useless.


Well, I spent some time trying to configure an ODBC driver found into
the admin tools of Windows. I have "declared" a specific ".mdb" file as
ODBC souce. I have used another tool (WinBatch) which can has sample
scripts for ODBC use and which can normally detect ODBC sources.

This script correctly sees my file as ODBC proposed source. But cannot
access to it. That's why I would like to make this access from Perl scripts.

I have no "SQL server" neither "anything else server" running on my
machine. Should I ? Should I use Win32::OLE ? DBD ? DBI ? ODBC ? or
maybe SHXK::-[~#GMKX ?

What is all the stuff to install / configure / run to finally get this
simple result : simply querying a simple database ?

TIA,

Micla.
 
P

Peter A. Krupa

use Win32::ODBC;

## $db = new Win32::ODBC ( "DRIVER=Microsoft Access Driver
(*.mdb);SystemDB=somedatabase.mdw;DBQ=somedatabase.mdb;UID=someusername;PWD=somepassword"
) or die ( $! ); // all arguments

$db = new Win32::ODBC ( "DRIVER=Microsoft Access Driver
(*.mdb);DBQ=c:\\Program Files\\Microsoft
Office\\Office\\Samples\\Northwind.mdb" ) or die ( $! );

$sql = 'SELECT DISTINCTROW TOP 10 Products.ProductName AS
TenMostExpensiveProducts, Products.UnitPrice FROM Products ORDER BY
Products.UnitPrice DESC;';

die $db->Error ( ) if $db->Sql ( $sql );

while ( $db->FetchRow ( ) )
{
print ( join ( "\t", $db->Data ( ) ), "\n" );
}

$db->Close ( );
 
M

Milca

Thank's one thousand times : despite the fact that it necessarily had to
work (and then should never have run at all), it has perfectly run,
rapidly, in total conformance with the "Manual", I have made my first
request without any problem, and - until here - the result is exactly
what it has to be ...!!! I've been very close to this result with the
tests I had made before (ODBC parameters good), but the result has
"exploded" only now !

Thank's again ! The face of the planet should change fast and soon, from
now ...! :)))

Micla.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top