Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: Accessing Access DB with DBI

by WhiteBird (Hermit)
on Jun 04, 2004 at 03:13 UTC ( #360652=note: print w/replies, xml ) Need Help??

in reply to Accessing Access DB with DBI

I have separate scripts that tap into both Access databases and an MS SQL server. I imagine that it would be easy enough to combine both calls into one script, get the data you need and do what you want.

I use Win32::ODBC for my connection to the MS SQL Server. I like the syntax that it uses to call stored procedures. A sample connection into the database would be something like:

my $db = new Win32::ODBC( "DSN=INFO;UID=id;PWD=password" ); if( ! $db ) { die "Error connecting: " . Win32::ODBC::Error() . "\n"; }

For my Access database connections I use dbi::ODBC and the call looks like:

my $dbh = DBI->connect("dbi:ODBC:INFO","username","password") or die "Unable to connect: " . $DBI::errstr . "\n";

Note the differences in the way the username and passwords are called in each case. You can either hard code the username and password into the call, or you can place them in a file out of the document root and refer to the file in your call. The "INFO" in each call points to the DSN that is set up through the Windows Admin tools on the server to connect to the database. I'm assuming if you have a DBA background, then you know how to do that.

Most of the information that I needed to understand how to use DBI and Win32::ODBC came from the documentation for the modules and from web searches. Dave Roth has helpful information on Win32::ODBC.

Hope this helps.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://360652]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2022-05-16 18:13 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (63 votes). Check out past polls.