It looks as though you are running CGI under a web server. The most common
reason for this issue is the mdb is on a mapped drive where the mapped driver
was mapped by a different user to the one the web server is running as.
However, there are loads of other reasons for this - search msdn.microsoft.com
which lists all the possibilities.

This URL in our FAQ lists many of them:

http://www.easysoft.com/products/9999/faq_answer.phtml?ID=686&product=2002

Martin
--
Martin J. Evans
Easysoft Ltd, UK
Development


On 31-Mar-2005 Moreno, Javier wrote:
> Kevin,
> 
> I tried removing the user and the pwd from the ODBC connect string but I am
> still getting 'Unable to connect to database'. Here is my code
> 
># Include CPAN modules for DB communication
> use DBI;
> use DBD::ODBC;
> 
># Use these pragmas to code correctly
> use strict;
> 
># Connect to the database, return error message if something went wrong
> $::dbh = DBI->connect('dbi:ODBC:CLUCTR', '', '', { AutoCommit => 0 }) or
>       &Error("Unable to connect to database.");
> 
> And on the log I get:
> 
> [Thu Mar 31 07:12:56 2005] [error] [client 151.110.117.153] DBI
> connect('CLUCTR','',...) failed: [Microsoft][ODBC Microsoft Access Driver]
> The Microsoft Jet database engine cannot open the file '(unknown)'.  It is
> already opened exclusively by another user, or you need permission to view
> its data. (SQL-HY000)(DBD: db_login/SQLConnect err=-1) at
> C:/oracle/ora92/Apache/Apache/ITTWeb/cgi-bin/CLUCTR.pl line 53\r, referer:
> http://slpmxwmorenojav/ITTWeb/cgi-bin/Welcome.pl
> [Thu Mar 31 07:12:56 2005] [error] [client 151.110.117.153] Died at
> Functions.pl line 139.\r, referer:
> http://slpmxwmorenojav/ITTWeb/cgi-bin/Welcome.pl
> 
> Line 139 is the die on my catch-all Error function
> 
># Useage:      Error (<any_error_text>, <optional_sql_code_to_display>)
> 
># This routine is a catch-all error routine. It will take in a reason for
># failure as a string and append the DBI
># returned error message. Then it will simply display it and die since there
># is no reason to go further and to ease
># research of error.
> sub Error {
> 
>       my ($error_string, $sql) = @_;
>       
>       # Print out error messages
>       print "<p align=\"center\" class=\"Warning\">$error_string</p>\n";
> 
>       # Perform the below only if we have an optional SQL parameter
>       if ($sql) {
>               
>               # Print the output from the SQL command
>               print "<p align=\"left\" class=\"Normal\">$sql</p>\n";
> 
>               # Output the DBI error string which should be available
>               print "<p align=\"left\" class=\"Normal\">$DBI::errstr</p>\n";
> 
>               # Before dying attempt a database disconnect just in case
>               $::rc = $::dbh->disconnect or die "FATAL ERROR. Unable to
disconnect from
> database.";
>       }
> 
>       # Unable to continue. We know why so just die
>       die;
> }
> 
> Regards,
> 
> Javier Moreno
> 
> -----Original Message-----
> From: Kevin Carothers [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, March 30, 2005 6:45 PM
> To: Moreno, Javier
> Cc: dbi-users@perl.org
> Subject: Re: Accessing MS Access through the DBI ODBC
> 
> 
> Hi Javier,
> 
>> I am trying to access an MS Access database via perl DBI and I am unable to.
>> I checked the security and there is only one 'Admin' user with no password
>> and I use that in my connection string. However, I cannot connect. Please
>> help.
>> 
> 
>  1.  Create an ODBC  connection via %SystemRoot%\system32\odbcad32.exe
>       Call the database connect name "ODBCName"
> 
>  2.   In your Perl code add:
> [---]
>    use DBI;
> [---]
>    $dbh = DBI->connect("dbi:ODBC:ODBCName",'','');
> [---]
>    $sth = $dbh->prepare("select * from some_tablename");
>    $sth->execute || die("Could not execute SQL statement ... maybe
> invalid?");
>    while (@row_data = $sth->fetchrow_array()) {
>        print $row_data[0];     ### print first column of table 
> 'some_tablename'
>        }
> 
> 
> ...That's really about it... everything else is on an as-needed basis.
> If the database is on a network drive, maybe there is some sort of 
> permissions issue going on.   Post some code.
> 
> kevindot

Reply via email to