Jump to content

Archived

This topic is now archived and is closed to further replies.

mphagan

ADODB ODBC connects to local drive but not network

Recommended Posts

Hello,

I developed code to connect via ADODB ODBC to a Visual Foxpro dbf file. Everything worked fine when the db file was on the local drive. When I change the path to a network drive map, the connect fails. I have tried on different network drive, using both a standard windows map and UNC.

Here is the code:

<?php

include('C:\Program Files\Internet\adodb\adodb.inc.php');
//include("C:\Program Files\Internet\adodb\adodb-exceptions.inc.php");

// Path to dbase file
// connects to file on local drive
//$db_path = "C:\Program Files\Internet\Apache\Apache2\htdocs";
// does not connect to network drive, using drive map or unc
//$db_path = "\\\Server\share";
$db_path = "T:\share";


$db =& ADONewConnection('vfp');
$dsn = "Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB=$db_path;Exclusive=No;";

$db->debug = true;
$db->Connect($dsn);

try {
$rs = $db->Execute("select * from dbftable");
} catch (exception $e) {
print_r($e);
}

if (!$rs) {
echo "Not Connnected!";
}

***************
The error I get is:

Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC Visual FoxPro Driver]File 'dbftable.dbf' does not exist., SQL state S0002 in SQLExecDirect in C:\Program Files\Internet\adoDB\drivers\adodb-odbc.inc.php on line 530
S0002: [Microsoft][ODBC Visual FoxPro Driver]File 'dbftable.dbf' does not exist.

ADOConnection._Execute(select * from dbftable, false) % line 856, file: adodb.inc.php
ADOConnection.Execute(select * from dbftable) % line 22, file: foxado.php

Not Connnected!
Fatal error: Call to a member function FetchRow() on a non-object in C:\Program Files\Internet\Apache\Apache2\htdocs\foxado.php on line 42

*************
This is running on PHP 5, ADO version 4.8.

Thanks, Mark

Share this post


Link to post
Share on other sites
Found the answer to my own question. Posting the answer, incase it will help someone else.

Turned out to be a rights issue. The account I was logged in as had rights to the network drive map, but apache did not. Apache was running as a service using "Log on as: Local System Account". The Local System account had no rights to the network resource. I changed Apache to run under a network account with rights to the mapped drive and the code works. Should have seen this earlier!

Mark

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.