3

I am trying to read visual foxpro .dbf files using php and getting the following error:

Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> Microsoft OLE DB Provider for Visual FoxPro<br/><b>Description:</b> Invalid path or file name.' in C:\xampp\htdocs\phpdbf\index.php:41 Stack trace: #0 C:\xampp\htdocs\phpdbf\index.php(41): com->Open('Provider=VFPOLE...') #1 {main} thrown in C:\xampp\htdocs\phpdbf\index.php on line 2

I have downloaded and run provider from here (note: not sure if I need to do any extra configuration - just simply run it).

Here is my code: (note: I am not sure about the "ADODB.Connection" and "Provider=VFPOLEDB.1" values in the code. let me know if they don't stand for defaults)

$conn = new COM("ADODB.Connection");
$conn->Open('Provider=VFPOLEDB.1;Data Source="C:\\xampp\\htdocs\\phpdbf;";');

//test.dbf is the file
$rs = $conn->Execute("SELECT * FROM test");

// Display all the values in the records set
while (!$rs->EOF) { 
    $fv = $rs->Fields("my_datetime");
    echo $fv->value."<br/>";
    $rs->MoveNext();
} 
$rs->Close(); 

Note: I have tried the answer here , but still getting this error.

3
  • Are you running a 32bit or 64bit version of XAMPP? I would take a guess that the foxpro stuff is only compiled for 32bit, could that be your problem?
    – RiggsFolly
    Aug 11, 2015 at 10:16
  • i am running a 32bit xampp on windows
    – aiiwa
    Aug 11, 2015 at 10:18
  • try getting rid of the semi-colon after the path where the tables are located... don't know if that is killing the connection.
    – DRapp
    Aug 16, 2015 at 22:48

1 Answer 1

1

Your data source needs to point at the visual Foxpro .dbc file. Example

Data Source="c:\\vfpdata\\mydatabase.dbc"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.