I can connect to a FoxPro database, but every query I try (such as "SELECT * FROM ARRPICS;") says that the file (in this case "arrpics.dbf") doesn't exist.
The Windows server is XP Pro, the client machine is Redhat 9/Apache/PHP.
Here's my connection code (which seems to work). The XP machine has the O: drive mapped to "\\gcsolems1\data" where all the FoxPro files are located (to which the XP account and Linux user's login both have read/write access):
function connect($stServer)
{
$bRet = true;
if ( ($this -> m_db = odbtp_connect($stServer,'Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB=O:;Exclusive=NO;')) == false)
{
print "Could not connect to the $stServer database";
exit;
}
odbtp_set_attr( ODB_ATTR_FULLCOLINFO, TRUE );
return $bRet;
}
And here's my query code:
function runQuery($stQuery,$bInTransaction = FALSE)
{
print "Running ODBTP query: $stQuery<br/>\n";
if ( ($result = odbtp_query($stQuery,$this -> m_db)) == FALSE )
{
print "ODBTP ERROR: " . $this -> getErrorMessage() . "\n";
print "Unable to run the query . . . Please try again. <br/>\n";
if ($bInTransaction)
{
print "<br/>Rolling back transaction and terminating script.\n";
$this -> rollback();
exit;
}
}
return $result;
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You need to run the ODBTP service under the user account that has the proper access rights. By default, it is installed under the local system account. You will have to change it using the Service Control Manager. Also, you might not be able to use O:. Instead you may have to use the UNC path mapped to O:.
-- bob
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I had to create a new XP account for the name I usually use to log into the server hosting our FoxPro files (I don't normally use this XP machine for anything, so I didn't have a pre-existing account for the server).
I then went to the services manager under XP, right clicked on the ODBTP service, selected properties, then selected the "Log On" tab, clicked on the "This account" radio button, entered the username and password, hit apply, then restarted the service.
I still get the same error message as before. I tried using O:, O:\, \\gcsolems1\data, \\gcsolems1\data\, \\\\gcsolems1\\data, and \\\\gcsolems1\\data\\, but none of them solved the problem.
Connecting is still working, but selects are all still failing with the same error message.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The problems turns out to indeed be a permissions problem. I was starting the XP service with a proper account and password, and the account name has access to the FoxPro server, but the password I was using for the XP account was not the same password I was using for the remote FoxPro account of the same name.
So the server started okay because the username and password were valid for the local machine, but the query was failing because the username/password pair was not valid for the remote server.
-whew-
I appreciate the help. :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It appears that you cannot use UNC paths in a FoxPro ODBC connect string, and drives are not mapped for services. So, you should try creating a System DSN for that database, and then use 'DSN=YourDSN' to connect to the database. I should also use the UNC path when creating the DSN.
-- bob
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Does anybody have a FOXPRO connection sample?
Especially the driver name.
Thank You
DRIVER={Microsoft Visual FoxPro Driver};SOURCETYPE=DBF;SOURCEDB=c:\YourDbfFileDir;EXCLUSIVE=NO;
-- bob
I can connect to a FoxPro database, but every query I try (such as "SELECT * FROM ARRPICS;") says that the file (in this case "arrpics.dbf") doesn't exist.
The Windows server is XP Pro, the client machine is Redhat 9/Apache/PHP.
Here's my connection code (which seems to work). The XP machine has the O: drive mapped to "\\gcsolems1\data" where all the FoxPro files are located (to which the XP account and Linux user's login both have read/write access):
function connect($stServer)
{
$bRet = true;
if ( ($this -> m_db = odbtp_connect($stServer,'Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB=O:;Exclusive=NO;')) == false)
{
print "Could not connect to the $stServer database";
exit;
}
odbtp_set_attr( ODB_ATTR_FULLCOLINFO, TRUE );
return $bRet;
}
And here's my query code:
function runQuery($stQuery,$bInTransaction = FALSE)
{
print "Running ODBTP query: $stQuery<br/>\n";
if ( ($result = odbtp_query($stQuery,$this -> m_db)) == FALSE )
{
print "ODBTP ERROR: " . $this -> getErrorMessage() . "\n";
print "Unable to run the query . . . Please try again. <br/>\n";
if ($bInTransaction)
{
print "<br/>Rolling back transaction and terminating script.\n";
$this -> rollback();
exit;
}
}
return $result;
}
Here is the actual error message:
Warning: [42S02][173][Microsoft][ODBC Visual FoxPro Driver]File 'arrpics.dbf' does not exist.
You need to run the ODBTP service under the user account that has the proper access rights. By default, it is installed under the local system account. You will have to change it using the Service Control Manager. Also, you might not be able to use O:. Instead you may have to use the UNC path mapped to O:.
-- bob
Thanks for replying so quickly.
I had to create a new XP account for the name I usually use to log into the server hosting our FoxPro files (I don't normally use this XP machine for anything, so I didn't have a pre-existing account for the server).
I then went to the services manager under XP, right clicked on the ODBTP service, selected properties, then selected the "Log On" tab, clicked on the "This account" radio button, entered the username and password, hit apply, then restarted the service.
I still get the same error message as before. I tried using O:, O:\, \\gcsolems1\data, \\gcsolems1\data\, \\\\gcsolems1\\data, and \\\\gcsolems1\\data\\, but none of them solved the problem.
Connecting is still working, but selects are all still failing with the same error message.
The problems turns out to indeed be a permissions problem. I was starting the XP service with a proper account and password, and the account name has access to the FoxPro server, but the password I was using for the XP account was not the same password I was using for the remote FoxPro account of the same name.
So the server started okay because the username and password were valid for the local machine, but the query was failing because the username/password pair was not valid for the remote server.
-whew-
I appreciate the help. :)
It appears that you cannot use UNC paths in a FoxPro ODBC connect string, and drives are not mapped for services. So, you should try creating a System DSN for that database, and then use 'DSN=YourDSN' to connect to the database. I should also use the UNC path when creating the DSN.
-- bob
Yes it would be great to have an example how to connect to Foxpro database form within Linux PHP
Sorry I though no answers were posted, forget my comment (for now)