Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Update: Using Perl to connect to an Access 10 database

by merrymonk (Hermit)
on May 30, 2019 at 20:46 UTC ( [id://11100744]=perlquestion: print w/replies, xml ) Need Help??

merrymonk has asked for the wisdom of the Perl Monks concerning the following question:

Recently I asked for help using Perl to connect to Microsoft Access 10
There were a number of suggestions one of which was that the problem may be due to whether I was using a 32 or 64 bit version of Perl.
I now have been able to use both a 32 bit and 64 bit version of Perl, which have come from the same place for the Perl below (adapted from one of the suggestions).
use strict; use DBI; my $dbfile = "c:/temp/Database.accdb"; my $dbh_ok = 'yes'; my $dsn = 'driver=Microsoft Access Driver (*.mdb, *.accdb);dbq='.$dbfi +le; my $dbh = DBI->connect("dbi:ODBC:$dsn", '', '') or ($dbh_ok = 'no'); if($dbh_ok eq 'no') { print "Access DBI connection failed - error\n$DBI::errstr\n"; } else { print "Access DBI connection made - handle <$dbh>\n"; }
With the 64 bit Perl I got the following.
>access_connect_pm.pz
DBI connect('driver=Microsoft Access Driver (*.mdb, *.accdb);dbq=c:/temp/Database.accdb','',...) failed: MicrosoftODBC Driver Manager Data source name not found and no default driver specified (SQL-IM002) at c:\temp\access_connect_pm.pz line 6.
Access DBI connection failed – error,/br> MicrosoftODBC Driver Manager Data source name not found and no default driver specified (SQL-IM002)

With the 32 bit Perl I got the following.
access_connect_pm.phz
Access DBI connection made - handle <DBI::db=HASH(0x2fbb8fc)>

So it does seem that it does matter whether a 32 bit or 64 bit Perl is used.
I guess there probably is a means of using a 64 bit version of Perl to make a connection to Access 10 but I do not know where to start to find out.

Replies are listed 'Best First'.
Re: Update: Using Perl to connect to an Access 10 database
by stevieb (Canon) on May 30, 2019 at 20:56 UTC

    It's been quite some time since I've done ODBC stuff, but on Windows, you have to create your DSN in two locations:

    64 bit - run %systemdrive%\Windows\SysWoW64\odbcad32.exe

    32 bit - run %systemdrive%\Windows\System32\odbcad32.exe

    Same binary name, but ridiculous locations for them. Where's the consistency!? ;)

      64 bit - run %systemdrive%\Windows\SysWoW64\odbcad32.exe
      32 bit - run %systemdrive%\Windows\System32\odbcad32.exe
      

      Like many people, you got your bits-vs-folder confused, because of Microsoft's insane naming scheme. SysWow64 means "Windows 32-bit on Windows 64-bit", and is the folder that holds the 32bit executables and DLLs for use on a 64bit OS. System32 kept it's historic name, even though in 64-bit OSes, it's the directory for the 64bit system files. See File System Redirector in MS online docs for even more.

        Thanks pryrt,

        You're absolutely right. Good grief!

Re: Update: Using Perl to connect to an Access 10 database
by holli (Abbot) on May 30, 2019 at 21:48 UTC
    Check out this old node of mine.


    holli

    You can lead your users to water, but alas, you cannot drown them.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11100744]
Approved by Paladin
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (7)
As of 2024-04-23 18:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found