Preparing Microsoft Access
Our focus on MS Access this month is not an endorsement, per
se, but because it is an easy-to-learn and popular database
application. Of course, we're not going to spend time on the
ins and outs of using the Access interface ... suffice it to
say, this article will have to assume that you have or can
figure out how to create a database within Access. To help
follow along, you might consider re-creating the sample
database we featured earlier in this article,
named clients, with two tables, billing and
invoices.
Now, let's cut to the chase: you have a database ready-to-go
in Microsoft Access and you're chomping at the bit to start
coding a Perl-based query script. First, you'll have to
register your Access database with Windows' ODBC,
or Open Database Connectivity, control. This will
allow our Perl modules to "speak" with the Access database,
as they share a common communication protocol. You can find
the ODBC control in the Windows Control Panel. Launch the
ODBC Data Sources control panel and select the
System DSN tab.
You can see that we've already added our clients
database to ODBC; you can do this by clicking "Add",
selecting the "Microsoft Access Driver (*.mdb)",
and then Finish. The next window lets you select a
Data Source Name, or DSN, which is the name of
this database as you'll refer to it from your Perl script.
We chose Clients (Windows systems are generally
case insensitive, although Perl itself is case sensitive),
as well as the actual database file you wish to register.
Voila! -- Perl will now be able to talk to
your Access database courtesy of the ODBC protocol.
Now that your Access database has been created and registered
with Windows' ODBC control panel, we can turn our attention
away from Access-specific information and look to Perl and all
the wonders within....