logo
Apache Lounge
Webmasters

 


About

Forum Index Downloads Search Register Log in  RSS Apache Lounge
 


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Apache Lounge is not sponsored.

Your donations will help to keep this site alive and well, and continuing building binaries.



Perl ADODB MS Access and "Provider cannot be found"

 
Post new topic   Reply to topic    Apache Forum Index -> Other Software



View previous topic :: View next topic  
Author Message
Rodentius



Joined: 15 Jun 2015
Posts: 2
Location: US

PostPosted: Mon 15 Jun '15 22:31    Post subject: Perl ADODB MS Access and "Provider cannot be found" Reply with quote

I'm on a Windows Server 2012 64-bit virtual machine. We're on an as-is bare bones kind of situation with no technical support and I'm thinking my problem has to do with permissions, accounts, and other sysadmin stuff I know nothing about.

I have a perl script which connects to an Access 2000 database (mdb) and it runs perfectly when I execute it from a command prompt. So I know it works. But it fails if I try and run it as a cgi-script in Apache. I know Apache cgi perl scripts work. It just can't make the database connection.

I've tried both as a service and running it via the console with the same results.

The error I get is:
Provider cannot be found. It may not be properly installed. Win32::OLE(0.1709) error 0x800a0e7a in METHOD/PROPERTYGET "Open"

The example program is below. This one uses a DSN-less connection but I've also tried creating a System DSN (C:\windows\sysWOW64\odbcad32.exe since Apache and perl are both 32-bit) but I get the same problem.

Code:
#!C:/apps/strawberry/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;
}


My environment:

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:\apps\strawberry\perl\bin>.\perl.exe -v

This is perl 5, version 16, subversion 1 (v5.16.1) built for MSWin32-x86-multi-thread

I've also tried to run the script on my local Windows 7 64-bit PC (not running as a service but rather from the cmd prompt, running as me). Again, the script works perfectly when executed from a cmd prompt but won't work in Apache cgi. But the problem here is a bit different. It doesn't even get to the Open statement. It fails to even create an ADODB.Connection object (i.e., my $conn = Win32::OLE->new("ADODB.Connection") doesn't return anything.) and I get an error Win32::OLE(0.1709): GetOleTypeLibObject() Not a Win32::OLE::TypeLib object. It's objecting to the use Win32::OLE::Const statement.

I've tried many things. One interesting post said I had to add these environment variables to httpd.conf:

SetEnv ProgramFiles "C:\Program Files"
SetEnv "ProgramFiles(x86)" "C:\Program Files (x86)"
SetEnv ProgramFilesW6432 "C:\Program Files"
SetEnv CommonProgramFiles "C:\Program Files\Common Files"
SetEnv "CommonProgramFiles(x86)" "C:\Program Files (x86)\Common Files"
SetEnv CommonProgramFilesW6432 "C:\Program Files\Common Files"

Unfortunately that didn't help.

I'm just about positive it's a permissions issue but I don't know where to begin. Any suggestions?
Back to top
Jan-E



Joined: 09 Mar 2012
Posts: 909
Location: Amsterdam, NL, EU

PostPosted: Tue 16 Jun '15 0:36    Post subject: Re: Perl ADODB MS Access and "Provider cannot be found& Reply with quote

Rodentius wrote:
I'm on a Windows Server 2012 64-bit virtual machine. We're on an as-is bare bones kind of situation with no technical support and I'm thinking my problem has to do with permissions, accounts, and other sysadmin stuff I know nothing about.

Not really a fix for your current problems, but did you ever consider using the mdbtools PHP extension? There is a Windows version php_mdbtools.dll in my builds.

Info on the extension:
https://pecl.php.net/package/mdbtools
Back to top
Rodentius



Joined: 15 Jun 2015
Posts: 2
Location: US

PostPosted: Tue 16 Jun '15 1:01    Post subject: Reply with quote

Thanks for the fast answer!

I don't think that would help in my situation. I have a lot of perl scripts using ADODB that need to be ported from an older Windows machine to a new one. Using anything other than ADO would require a complete rewrite of everything.

It's the same reason I can't use perl DBI or even DBD::ADO (let alone PHP). The code relies heavily on datashaping and neither DBI or DBD::ADO support that.
Back to top


Post new topic   Reply to topic    Apache Forum Index -> Other Software
Page 1 of 1