So why does it work perfectly from a command prompt and not through cgi? Is it Apache or Perl that's not looking for a 32-bit ODBC driver? I have tried both a DSN-less connection string as well as registering a 32-bit ODBC data source using C:\windows\sysWOW64\odbcad32.exe and get the same results. My simple test script is below but first my system particulars:
XAMPP for Windows v 5.6.8
C:\xampp\apache\bin>.\httpd.exe -V
Server version: Apache/2.4.12 (Win32)
Apache Lounge VC11 Server built: Jan 28 2015 16:48:40
Server's Module Magic Number: 20120211:41
Server loaded: APR 1.5.1, APR-UTIL 1.5.4
Compiled using: APR 1.5.1, APR-UTIL 1.5.4
Architecture: 32-bit
Server MPM: WinNT
threaded: yes (fixed thread count)
forked: no
Server compiled with....
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses disabled)
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=256
-D HTTPD_ROOT="/apache"
-D SUEXEC_BIN="/apache/bin/suexec"
-D DEFAULT_PIDLOG="logs/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_ERRORLOG="logs/error.log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"
C:\xampp\perl\bin>C:\xampp\perl\bin\perl -v
This is perl 5, version 16, subversion 3 (v5.16.3) built for MSWin32-x86-multi-t
hread
Copyright 1987-2012, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
And now here is my test script that, again, works perfectly from the command prompt:
- Code: Select all
#!"C:\xampp\perl\bin\perl.exe"
use Win32::OLE;
use Win32::OLE::Const 'Microsoft ActiveX Data Objects';
use strict 'vars';
my $db = 'C:\xampp\cgi-bin\anthro_pub.mdb';
print "Content-type: text/plain\n\n";
my $conn = Win32::OLE->new("ADODB.Connection");
my $rs = Win32::OLE->new("ADODB.Recordset");
my $dsn = "PROVIDER=MSDataShape;DRIVER={Microsoft Access Driver (*.mdb)};DBQ=$db;UID=;PWD=;";
$conn->Open($dsn) or print Win32::OLE::LastError();
my $sql = 'SELECT * FROM "Faculty Names"';
$rs->Open ($sql, $conn, 1, 1);
while (!$rs->EOF) {
my $name = $rs->Fields("Name")->value;
print "$name\n";
$rs->MoveNext;
}
By the way, I've tried a number of different provider strings with no luck, but there might be one that works I haven't stumbled upon yet. I use a lot of data shaping in my programs so typically use MSDataShape but I think other providers may work too.